JavaScript - Receiving Two Diff. Echo's From Php Script
Hi,
I have made this php script which checks two variables (nick and email): script.php PHP Code: <?php if (isset($_GET['nick'])) { $name = 'aurimas'; $ats = $_GET['nick']; if ($name == $ats) {echo "Užimtas";} else {echo "Laisvas";} } if (isset($_GET['email'])) { $email = 'auriaks@gmail.com'; $get_mail = $_GET['email']; if ($email == $get_mail) {echo "Užimtas";} else {echo "Laisvas";} } ?> And I use this Ajax script to get the answers from script.php PHP Code: // Get the HTTP Object function gethttpObject(){ if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) return new XMLHttpRequest(); else { alert("Your browser does not support AJAX."); return null; } } // Change the value of the outputText field function setOutput(){ if(httpObject.readyState == 4){ document.getElementById('answer').innerHTML = httpObject.responseText; } } // Implement business logic function doWork(){ httpObject = gethttpObject(); if (httpObject != null) { httpObject.open("GET", "script.php?nick=" + document.getElementById('nikas').value + "&email=" + document.getElementById('email').value, true); httpObject.send(null); httpObject.onreadystatechange = setOutput; } } setInterval(doWork, 100); var httpObject = null; The problem is, that I want to get those answers in different places of the page. PHP Code: <div id='td'>Nikas* |Tik mažosios raidės|</div> <div id='td'><input MAXLENGTH=20 type="text" size='27' id='nikas' name="nick" value="<?php echo $_POST['nick']; ?>">ONE HERE(WORKS)<div id='answer'></div></div> <div id='td'>E-paštas*</div> <div id='td'><input MAXLENGTH=60 type="text" size='27' id="email" name="email" value="<?php echo $_POST['email']; ?>">ANOTHER HERE(DONT WORK)</div> taisyklėmis. The aim is to check if the nick and email already exists ant tell user this info by saying "užimtas"(exists) or "Laisvas"(available) THANKS in ADVANCE Similar Tutorialsok, so i am working on this site www.davidmolnarphotography.com/blog i am trying to display the image description at the top of the page. i have accomplished this by using this code: Code: <div id="info_wrapper"> <div id="info_content"> <h6 class="cufon"><div id="info"><?php echo $all_photo_arr[0]->post_content; ?></div></h6> </div> </div> it works great! but it dosent switch when i switch the images ;( so i added this to the javascript that switches the pictures. Code: //switch image function SwitchImage(img){ $jpreloader.fadeIn("fast"); //show preloader var theNewImg = new Image(); theNewImg.onload = CreateDelegate(theNewImg, theNewImg_onload); theNewImg.src = img; document.getElementById("info").innerHTML= "<?php echo $all_photo_arr[0]->post_content; ?>" ; } it didnt work. if i replace "<?php echo $all_photo_arr[0]->post_content; ?>" with "img" it will pull the image url and switch but i cant figure out how to get the description ps... did i mention this is in wordpress Hi Experts, I am sorry if this is a beat up question... I have a form with three fields that capture Amounts in $: Field1: Invoice_Amount (calculated using SQL Query from Invoice table - Display only) Field2: Amount_Paid - Will be entered by admin Field3: Amount_Due - Should be autocalculated based on Field1-Field2 I want to put an onChange event on Field2 so that when user tabs out of that field then Field3 is automatically calculated. Any help would be appreciated. Thanks Vinny Hey all, I'm trying to email this form to myself using jQuery.ajax script but for some reason I'm not getting the emails. Here is my html for where the jquery exists on: Code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Form</title> <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/> <link rel="stylesheet" href="css/template.css" type="text/css"/> <script src="js/jquery-1.6.min.js" type="text/javascript"> </script> <script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"> </script> <script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"> </script> <script src="js/formcalculations.js" type="text/javascript" charset="utf-8"> </script> <script> var result = new Array(); result[4400]= "<h3>Category One - $4,400/Year</h3><ul><li>Allergy & Immunology</li><li>Endocrinology</li><li>Pathology</li><li>Dermatology</li><li>Geriatrics</li><li>Physical Rehabilitation</li></ul>"; result[6900]= "<h3>Category Two - $6,900/Year</h3><ul><li>Family Practice</li><li>General Practice</li><li>Internal Medicine</li><li>Onconlogy</li><li>Oral Surgrey</li><li>Radiology</li><li>Gastroenterology</li><li>Infectious Disease</li><li>Nephrology</li><li>Ophthalmology</li><li>Pediatrics</li><li>Urology</li></ul>"; result[9000]= "<h3>Category Three - $9,000/Year</h3><ul><li>Anesthesiology</li><li>Cosmetic Surgrey</li><li>General Surgrey</li><li>Neurology</li><li>Otolaryngology</li><li>Plastic Surgery</li><li>Vascular Surgery</li><li>Cardiology</li><li>Emergency Medicine</li><li>Gynecology</li><li>Orthopedic Surgery</li><li>Pain Management</li><li>Pulmonary Surgery</li></ul>"; result[9900]= "<h3>Category Four - $9,900/Year</h3><ul><li>Neurological Surgery</li><li>Obstetrics</li></ul>"; function sendForm() { var user = jQuery("#username").val(); var address = jQuery("#address").val(); var phone = jQuery("#phone").val(); var practice= jQuery("#practice").val(); var society= jQuery("#society").val(); var phone = jQuery("#phone").val(); var bare = jQuery("#baredefense"); var insured = jQuery("#insureddefense"); var interested = ""; if( bare.attr("checked") == "checked" && insured.attr("checked") == "checked" ) { interested = "Bare Defense And Insured Defense"; }else if(bare.attr("checked") == "checked") { interested = "Bare Defense"; }else if(insured .attr("checked") == "checked") { interested = "Insured Defense"; }else { interested = "";} var titleSociety = jQuery('#society option:selected').text(); var fdata = "username="+name+"&address="+address+"&phone="+phone+"&practice="+practice+"&society="+titleSociety+"&interested="+interested; var content = "Practice Field: "+practice+"<br />Medical Society: "+titleSociety+"<br />Interested in: "+interested; var res = calculateTotal(); jQuery("#CalculationResult").html(content+"<br /><br />"+res); jQuery.ajax({ url: "js/ajax.php", data: fdata, method: "GET", success: function(r) { // setTimeout("clearForm()", 2000); } }); return false; } jQuery(document).ready(function(){ // binds form submission and fields to the validation engine //jQuery("#quoteform").validationEngine(); jQuery("#quoteform").validationEngine('attach', { onValidationComplete: function(form, status){ if(status == true) { sendForm(); } return false; } }); }); function clearForm(){ //jQuery("#quoteform").hide(); document.getElementById('quoteform').reset(); jQuery("#quoteform").validationEngine('hideAll'); return false; } </script> </head> <body> <form id="quoteform" class="formular" method="post"> <fieldset> <legend> How Much Will My Pre-Paid Legal Defense Cost? </legend> <div class="FormContainer"> <label> <span>Name *: </span> <input value="" class="validate[required] text-input" type="text" name="username" id="username" /> </label> <label> <span>Address *: </span> <input value="" class="validate[required] text-input" type="text" name="address" id="address" /> </label> <label> <span>Phone number *: </span> <input value="" class="validate[required,custom[phone]] text-input" type="text" name="phone" id="phone" /> </label> <label> <span>Choose Your Practice Field *:</span> <select name="practice" id="practice" class="validate[required]"> <option value="">--Select Field--</option> <option value="Allergy and Immunology">Allergy and Immunology</option> <option value="Endocrinology">Endocrinology</option> <option value="Pathology">Pathology</option> <option value="Dermatology">Dermatology</option> <option value="Geriatrics">Geriatrics</option> <option value="Physical Rehabilitation">Physical Rehabilitation</option> <option value="Family Practice">Family Practice</option> <option value="General Practice">General Practice</option> <option value="Internal Medicine">Internal Medicine</option> <option value="Oncology">Oncology</option> <option value="Oral Surgery">Oral Surgery</option> <option value="Radiology">Radiology</option> <option value="Gastroenterology">Gastroenterology</option> <option value="Infectious Disease">Infectious Disease</option> <option value="Nephrology">Nephrology</option> <option value="Ophthalmology">Ophthalmology</option> <option value="Pediatrics">Pediatrics</option> <option value="Urology">Urology</option> <option value="Anesthesiology">Anesthesiology</option> <option value="Cosmetic Surgery">Cosmetic Surgery</option> <option value="General Surgery">General Surgery</option> <option value="Neurology">Neurology</option> <option value="Otolaryngology">Otolaryngology</option> <option value="Plastic Surgery">Plastic Surgery</option> <option value="Vascular Surgery">Vascular Surgery</option> <option value="Cardiology">Cardiology</option> <option value="Emergency Medicine">Emergency Medicine</option> <option value="Gynecology">Gynecology</option> <option value="Orthopedic Surgery">Orthopedic Surgery</option> <option value="90Pain Management00">Pain Management</option> <option value="Pulmonary Surgery">Pulmonary Surgery</option> <option value="Neurological Surgery">Neurological Surgery</option> <option value="Obstetrics">Obstetrics</option> </option> </select> </label> <label> <span>Are You Affiliated With Any of the Following Medical Societies *:</span> <select name="society" id="society" class="validate[required]"> <option value="">--Select Society--</option> <option value="0">No, I am not</option> <option value="BCMA">Broward County Medical Association</option> <option value="DCMA">Dade County Medical Association</option> <option value="FOGS">Florida Obstetrics & Gynecology Society</option> <option value="FNS">Florida Neurological Society</option><option value="PBCMS">Palm Beach County Medical Society</option><option value="FSPS">Florida Society of Plastic Surgeons</option> </select> </label> <label> <span>What Type of Defense Are You Interested In? *:</span><br /> Bare Defense <input type="checkbox" value="5" id="baredefense" name="baredefense" class="d"><br />Insured Defense <input type="checkbox" value="5" id="insureddefense" name="insureddefense" class=""> </label> <input class="submit" onclick="clearForm();" type="reset" value="Reset!"/> <input class="submit" type="submit" value="Submit!"/><hr/> </div> <div class="CalculationContainer"> <div id="CalculationResult"> Please select.... </div> </div> </fieldset> <!-- <fieldset> <legend> Equals </legend> <label> <span>Password : </span> <input value="karnius" class="validate[required] text-input" type="password" name="password" id="password" /> </label> <label> <span>Confirm password : </span> <input value="kaniusBAD" class="validate[required,equals[password]] text-input" type="password" name="password2" id="password2" /> </label> </fieldset> --> </form> </body> </html> Hey guys, I am doing a website and the way it is suppose to work is when you click on a link there is a little triangle beside it, so when you click on it the triangle is suppose to face down but more links appear when you click on it. Anyways here is the code if someone could please tell me what im doing wrong? HTML Code: <ul class="menu" id="subnavmenu"> <li><a href="#" onClick="showHide('sublist1');return false;" id="subheading">About Us</a> <ul id="sublist1" style="display:none;"> <li><a href="#">Visit Us</a></li> <li><a href="#">Contact Us</a></li> <li><a href="#">Archives Unboxed and Revealed</a></li> </li> </ul> CSS Code: #subnavmenu ul.menu { display: block; overflow:hidden; } JAVASCRIPT Code: function showHide(element_id) { if (document.getElementById && document.getElementById(element_id) && document.getElementById(element_id).style) { var menu = document.getElementById(element_id); var arrow = document.getElementById(element_id + '_arrow'); if (menu.style.display == "block") { menu.style.display = "none"; if (arrow.src) { arrow.src = arrow.src.replace("down","right"); } } else { menu.style.display = "block"; if (arrow.src) { arrow.src = arrow.src.replace("right","down"); } } } } Hi, I am having a Main homepage in my site which contains many pages rendered from different sources. And all these rendered pages are having a table like <table id="toc" class="toc"></table> . As all these are rendered in my homepage , those tables are appearing in my homepage.. I am trying to remove these tables from my homepage coding by javascript. So i tried with a onload option to remove it .. But i dono how to do this. Since by any way only one table in the first page rendered is removed and all others are having the table.. How can i do this?? Please help me.. Hey guys, I've been searching for a few hours and haven't been able to find a code snippet to see if this is available. I'm attempting to pass text from my website to another website that has a form setup on it. I'd like to fill in the pertinent data for my users on the page that I load for them. I cannot make any changes to the receiving page as it is run by another company. I've pasted some of the code that is available on the receiving form. Thanks for any help. Code: <script type="text/javascript"> //<![CDATA[ var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]> </script> <input name="txtBranch" type="text" maxlength="4" id="txtBranch" tabindex="1" style="height:14px;width:35px;" /> <input name="txtClient" type="text" maxlength="11" size="11" id="txtClient" tabindex="2" style="height:14px;" /> Im trying to fill in the data in these 2 input fields. This doesn't seem to work... Code: document.getElementById("mydiv<?php echo $gigid; ?>").innerHTML = "<img src='Images/icons/loading.gif' />"; I want it basically to be this Code: document.getElementById("mydiv1234").innerHTML = "<img src='Images/icons/loading.gif' />"; Am I doing something wrong? Hi All, I have two scripts which I want to try and integrate. I am using a nice gallery script to show thumbnails which are appended to a an image wrapper which on click of the thumbnail shows the larger image in the image wrapper, I am trying to implement cloud zoom which is a plugin which uses image srcs to then point to an anchor href to show another larger zoom image either in the same place.. which is what I am trying to do or in another div beside. I have had to set me img srcs up in a certain way to easily enter some product details. and I need to try an manipulate the code to make it work to suit my file layout. I am using a var= images [ with a series of file locations and info such as below { src: 'romanticabride/thumbs/tn_Shauna.jpg', srcBig: 'romanticabride/images/Shauna.jpg', title: 'Shauna', longDescription: '<b><H1>Shauna</H1></b><br><b>Romantica Of Devon <br><br><h2>Sizes Available:</h2><br> 6 - 32.<b><br><b><br><b><b><b><H2>Colours Available:</h2><b><br>Various<br>Please Enquire Below<br><br><br><br><a href="mailto:tracy@cherishbridal.co.uk?subject=Web Enquiry Regarding Romantica Shauna Bridal Gown"class="enquiry rose glow" >Click To Enquire About This Item </a>' }, what I need is for cloud zoom to work when the main image wrapper is hovered over which means it will need to add a class or when the whichever srcBig: is hovered over it gets wrapped by href to make the script work . one of my pages is http://www.cherishbridal.co.uk/romaticabride.html the cloud zoom script is at http://www.professorcloud.com/mainsite/cloud-zoom.htm.. I am happy to share a jsfiddle with someone or explain further or post some code. Thank you in advance Hello, I would like to know which statement I should use in order to echo an iframe in JS. Thanks, Ben Hello, I believe this is something simple that I'm missing. I'm still fairly new to both js and php (and this may be a better question for the php forum - hopefully it makes sense though). What I have is a js function which uses the date/time to generate a 'unique' number onLoad, and places this number in the HTML as text in a <td></td>. This works fine. I'm also doing the same thing with the value attribute of a <input type="hidden"> element, which also works fine. The problem is, when I submit my form, php refuses to echo the value (but reports no errors). Here is all the relevant code: The HTML: Code: <td class='dandt' id='iquotenum' colspan='2'></td> The Javascript: Code: function loaded() { var d = new Date(); var vqtnum = document.getElementById("quotenumber"); var iqtnum2 = document.getElementById("iquotenum"); var vqtdat = document.getElementById("quotedate"); vqtnum.innerHTML = "" + (d.getMonth()+1) + d.getDate() + d.getFullYear() + "-" + d.getSeconds(); iqtnum2.innerHTML = "<input type='text' name='iqtnum' id='iqtnum' value='" + (d.getMonth()+1) + d.getDate() + d.getFullYear() + "-" + d.getSeconds() + "'></input>"; vqtdat.innerHTML = "" + (d.getMonth()+1) + "/" + d.getDate() + "/" + d.getFullYear(); } The PHP: Code: <?php $iqtnum = $_GET['iqtnum']; echo "<tr><td>Quote Number: </td><td>" . $iqtnum . "</td></tr>"; ?> I've verified by using Chrome's inspect element tool that the value attribute is being set correctly by my script, and I've got a few other php echos that get the user's input from other text boxes which use the same method*, and which work fine. Also while debugging I changed the type from hidden to text so I can see it easier. *Except that the value in this case is typed into the box, rather than generated by js. Thanks in advance. edit: I forgot to mention that I also have in the body tag of the HTML onLoad="loaded()". does any expert know how to pass parameters in the <script ..> tag? for instance; Code: <script type="text/javascript" src="script.js ?param1=val1¶m2=val2&etc "> in the javascript script.js, how would we read the params after the question mark? for example, google this; google shopping cart /v2_2/cart.js I have a script that works in seamonkey(my html editor) but when I use it in IE8 it says errors happen. Here's the code (the first line is on line 7 of the html file): Code: <script type="text/javascript"> function enlarge(imageNum) { var numToString = ""; if(parseInt(imageNum) < 10){ numToString = "0" + imageNum; } else { numToString = imageNum + ""; } window.open("images/LgScreenshot"+numToString+".jpg","Screenshot "+imageNum,"status=0,height=675,width=900,resizable=0"); } </script> And the errors: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB0.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.3; .NET CLR 3.0.30729) Timestamp: Wed, 10 Feb 2010 14:58:16 UTC Message: Object expected Line: 150 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html Message: Invalid argument. Line: 18 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html Hey everybody! I am trying to do a simple echo onclick, but despite what I try to do, it shows no errors, but won't work. I've tried things like: Code: echo "<div onclick=\"alert('test');\">t</div>"; echo '<div onclick="alert(\'test\');">t</div>'; But just can't seem to get it to work right. I'm trying to do this on a script that is being eval on the ajax request. Thus I'm having problems placing the ',", \ marks. Thanks for your time. I have a display hidden div code that works great, as seen: Code: <a href="javascript:InsertContent('login-popdown');>Login</a> but the problem is that when I put this in a PHP echo, like so PHP Code: // retrieve the session information $u = $_SESSION['username']; $uid = $_SESSION['loginid']; // display the user box echo " <span class='toplinks'><a href='javascript:InsertContent('login-popdown');'>Log In</a> - <a href='http://www.tomhilsee.com/ipool/system/register.php'>Register</a></span>"; the javascript does not work because the ' interferes I'm assuming. So is there a way to accomplish the show/hide without using some sort of code that would interfere with the php echo? I have a form, that when the user click Submit, I need a php variable to be echoed to the page. This is for an upload page. So when they are waiting for the file to upload, it will say "Uploading..." until the upload is complete. All I know so far is I need to create a javascript function and include it in the submit button. This is all I have so far in the submit button tag: onClick="Transferring();" Now I need to figure out the code to include in this function. Any ideas? I need to assign a key in the javascript to actually make the javascript work,. I have a bookmark in chrome , a javascript , which actually works when clicked on it .,. but how can i edit it so that i can actually make it work on click a key or combination of keys. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. Thanks in advance ., Nani Ok I am very very new to java to the point where I only know how to use pre-made javascripts in my php code so be gentle. First, here is part of a form I have: Code: <select name = "pulmonologist" > <option selected="" value="">---Select--- <option value="none">None</option> <?php while ($row2 = mysql_fetch_assoc ($results2)) { ?><option value = "<?php echo $row2['staff_name'];?>"><?php echo $row2['staff_name'];?></option> <?php } ?> </select> Ok now I want to echo the value that the user selects on the SAME page (i.e. before the submit button is pressed) (so I can't do it with php, I need javascript) like this: Code: <input type="submit" value = "Contact <?php echo $pulmonologist;?>" /> Can you tell me how to do this? Thanks! On this website: http://evancoleman.net/index.php I really like on the top how the menu has like 5 or 6 icons, and when you hover over them it shows a bubble with the name in them. Does anybody know where I can find this script? Thanks. Hello again . If these questions concerning Regular Expressions are inappropriate in this forum please let me know . Thank You. This expression <script[^>]*>.*?</script> matches ... Code: <script type="text/javascript">var cnnIsHomePage = true;</script> but not ... Code: <script type="text/javascript"> var cnnIsHomePage = true; </script> Please , how can i match the latter ? Hi I have found a script I would like to make a few changes to.. I have tried a few tricks but got me no-where. If you could help me I will be very much appreciated! Code: <HEAD> <script language="javascript"> <!-- //These are the names of the people you don't want //To add a person, just put their name in quotation marks //and add a comma after Names = new Array( "test1@email.com", "test2@email.com", "test3@email.com", "test4@email.com", "test5@email.com") function Check() { //Change FORM and FIELD to the form name and field name throughout this function namechk=document.FORM.FIELD.value.toLowerCase() awdrgy = 0 aLeRt = 0 while (awdrgy<=Names.length-1 && aLeRt!=1) { if (namechk==Names[awdrgy]) { aLeRt = 1 alert("Either your account is suspended or you entered an invalid email address! Please try again.") document.FORM.FIELD.value="" } awdrgy++ } } --> </script> </HEAD> <BODY> <form name="FORM"> <input name="FIELD" onblur="Check();" onblur> <input type="button" onclick=storytest() value="Submit" class="form"> </form> <!-- Script Size: 2.01 KB --> Basically What I want to happen is.. If a email entered that is listed in the reject list they will get an alert. (This currently does this) If a email was entered that's not listed it will submit the form. (Currently does not do this) I am making a login form that is complete but I wanted to add the above code to it.. If you or anyone could make it work the way I explained above I will be very much appreciated. Thanks, Chris |