JavaScript - Javascript Not Receiving The Correct Response
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"); } } } } Similar TutorialsHi Guys, I am having a small problem in my Javascript when I am using HTTPRequest. I am unable to recieve my Response back from server (Java Servlet) in time. I am using following code; Code: // Following function will simply goes to the Server and check if provided class is present function verifyClass(clsName) { var url = "checkServlet?className=" + clsName; var chkResult = ""; var httpReq = null; // Create an ActiVEX control object according to BRowser we are using httpReq = GetXmlHttpObject(); if (httpReq == null) { alert ("AJAX Request Failed!!! - Your browser does not support AJAX - Skipping CLASS Check."); } else { // First prepare ourself to recieve a response from server // Following code will simply wait untill server finish its response httpReq.onreadystatechange = function(){ if(httpReq.readyState == 4){ chkResult = httpReq.responseText; } } // Setup a request parameters httpReq.open("GET", url, true); // Send the request httpReq.send(null); } // Return the response recieved return chkResult; } I am using FireBug (plugin with my Firefox) to debug the HTML and I can see the response in it but when I am putting 'alert' before return the variable 'chkResult' is empty. Your suggestion will be appreciated; Thanks, -- SJunejo i have a drop down which triggers a ajax call. The ajax response is a form with various fields depending upon the drop down option selected. I have a text field in that response form which is to input the date. i have a calender widget and wish to display that as a popup with an onfocus or onclick on that text field. But becoz of the ajax response it does not let me do it. I know the problem is in the creation and destruction of the element where the calender has to be displayed so i tried putting the callender intiialization function in another function and calling that onclick but id doesnt work. below is my modified javascript code for the initialization of the calendar. Code: <script type="text/javascript"> var calendar1, calendar2, calendar3; /*must be declared in global scope*/ /*put the calendar initializations in the window's onload() method*/ function cal_init() { alert("hi"); calendar1 = new Epoch('cal1','popup',document.getElementById('calendar1_container'),false); calendar2 = new Epoch('cal1','popup',document.getElementById('calendar2_container'),false); calendar3 = new Epoch('cal1','popup',document.getElementById('calendar3_container'),false); }; </script> Hello coding forum users, I am working on the only javascript chapter of my HTML textbook. It asks me to: Quote: replace the line <img id="sky" src="sky0.jpg" alt=""/> with a script element that writes the following HTML code: <img id='sky' src='mapNum.jpg' alt=' ' /> where mapNum is the value of the mapNum variable. so I try PHP Code: <script type="text/javascript" /> document.write("<img id='sky' src='mapNum.jpg' alt=' ' />") </script> after a few other attempts I search codingforums and find: PHP Code: document.write("<img id=\"sky\" src='sky"+mapNum+".jpg' alt='' />"); and PHP Code: document.write('<img id="sky" src="sky'+mapNum+'.jpg" alt="" />'); and these work perfectly fine but I don't understand why? my textbook only has one javascript chapter and its really small and vague, and my teacher hasn't answered my emails, so I would be grateful if anyone can tell my why my first code falls flat. I found and am using the following script to add checkbox values to a textarea. Code: <script type="text/javascript"> function add_sub(el){ if (el.checked) el.form.elements['type'].value+=el.value; else{ var re=new RegExp('(.*)'+el.value+'(.*)$'); el.form.elements['type'].value=el.form.elements['type'].value.replace(re,'$1$2'); } } </script> </head> <body> <form name="form1" method=post> <textarea name="type" rows="5" cols="35" onclick="this.focus();this.select();"> </textarea><br> <input type="checkbox" name="bob" id="bob" value="<p>" onclick="add_sub(this);"><label for="bob"><p></label><br> <input type="checkbox" name="bob1" id="bob1" value="<span>" onclick="add_sub(this);"><label for="bob1"><span></label><br> <input type="checkbox" name="bob2" id="bob2" value="<div>" onclick="add_sub(this);"><label for="bob2"><div></label> That is working. However, I wanted to put carriage returns after each checkbox value added, so I added the + "\r\n" as follows: Code: <script type="text/javascript"> function add_sub(el){ if (el.checked) el.form.elements['type'].value+=el.value + "\r\n"; else{ var re=new RegExp('(.*)'+el.value+'(.*)$'); el.form.elements['type'].value=el.form.elements['type'].value.replace(re,'$1$2'); } } </script> That is working when adding the value, but removing the value when the checkbox is unchecked is not working. I know the regular expression, etc. needs to be updated to account for the carriage returns, but I have tried everything I can think of and cannot get it to work. Help correcting the code is appreciated. Whats wrong with the code below? I'm trying to get the email service provider name. Code: <html> <head> <script type="text/javascript"> function GetProvider { var fullemail = openinviter.email_box.value; var afterat = fullemail.split("@"); var Provider = afterat[1].split("."); var showit = Provider[0]; openinviter.provider_box.value=showit; } </script> </head> <body> <form action="" method="post" name="openinviter"> <input type="text" name="email_box" onchange="GetProvider()" /> <input type="text" name="provider_box" value=""> </form> </body> </html> Thanks alot! Sorry if this is the wrong forum for this question. I get confused about what forum to post a question in with regards to DHTML technologies since they are all frequently used together. Anyhoo, heres my question. I've recently discovered an interesting behavior. When I mouse over a nested element it triggers the 'onmouseout' event handler of the parent element. Take the following code snippet, for instance: Code: <table> <tr> <td onmouseout="window.alert('you moused out of td');"> <img src="image0.gif" style="height:50px; width:50px;" /> </td> </tr> </table> In the code snippet above, the 'onmouseout' event handler executes when you mouse over the image nested inside the <td> element. I wouldn't have thought this would be the appropriate behavior since from my perspective the mouse is still inside the <td> element. Can someone make comments on this. Thank You. Edit: I've discovered that mousing over a nested element causes both an 'onmouseout' and an 'onmouseover' event for the parent element. They are called back to back. Seems a little bit of an odd sequence of events but maybe it makes sense in the grand scheme of things. Yeah, right. Box 1 - Box 2 / Box 3 and i put a round off number so the decimals dont give a million numbers the problem is...the math is wrong now.... someone please help me fix this.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Calc</title> <script type="text/javascript"> function calculate() { var one = document.getElementById("one").value*1; var two = document.getElementById("two").value*1; var three = document.getElementById("three").value*1; document.getElementById("answer").value=((one-two)/three); ; } </script> </head> <body> Enter Number 1 <br> <br><input type="text" id="one" /><hr>Enter Number 2<br><br><input type="text" id="two" /><br><br><hr>Enter Average number<br><br><input type="text" id="three" /><br><br><button onclick="calculate();">Calculate</button> <br id="result"></center></br> Total <input type="text" readonly="readonly" id="answer" /><br><br></center> </body> </html> </td> </tr> </table> </center> </body> </html> i am dynamically making pdf files, works great using abcpdf etc etc. the only problem that i am having is with the page breaking. i want to create a function that runs onload and can read the position of elements and add breaks before the element if it is cut off. each block ("from the west", "holiday inn express") is a span with the class name of "entry" i want to loop through those, get their height, add them together and if that span falls in the range of the page size (792px) add a page break before it. the difficult part will be when we get to pages 2 and above does that make sense? im throwing around some ideas now in a js file, if you have any please post them thanks Hi, i have a complete validation code here which seems not working properly.When i filled the full name filed and i click submit, the form get submitted but when i filled the full name and filled email too and click on submit the third or fourth like country alert or helpmessage pop up. Now i am trying to fish out why it is doing that but i am not getting it now. please i know its a long code but please try to help me on where i am wrong. I will thank you for using blue thank Please i will suggest copy the code i see what i mean.Here is it Code: <html> <head> <title>Final form validation</title> <script type="text/javascript"> function formvalidator() { var Fullname=document.getElementById("Fullname"); var email=document.getElementById("email"); var addr=document.getElementById("addr"); var country=document.getElementById("country"); var zip=document.getElementById("zip"); var phone=document.getElementById("phone"); var educa=document.getElementById("educa"); var job=document.getElementById("job"); var hours=document.getElementById("hours"); if(Checkfullname(Fullname,"Please enter your full name.")){ if(Checkemail(email,"Please enter a valid email.")){ if(Checkaddr(addr,"Please enter your address for better contact.")){ if(Checkcountry(country,"Please select a country.")){ if(Checkzip(zip,"Please enter your area zip code of 5 digits.")){ if(Checkph(phone,"Please enter your phone number for better contact of 14 digits.")){ if(Checkeduca(educa,"Please select your education status.")){ if(Checkjob(job,"Please select job.")){ if(Checkhours(hours,"Please select the number of hours you want to work." )){ return true; }}}}}}}}} return false; } function Checkfullname(elem,helpmg) { var eval=elem.value; eval=eval.replace(/[^a-z\s\-\.\']/gi,""); eval=eval.replace(/^\s+|\s+$/g,""); eval=eval.replace(/\s{2,}/g," "); eval=eval.toLowerCase().replace(/\b[a-z]/g,function(w){return w.toUpperCase()}); document.getElementById("Fullname").value=eval; if(eval.length>=5 && eval.length<=50){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkemail(elem,help) { var eReExp=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(eReExp)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkaddr(elem,helpmg) { var eval=elem.value; eval=eval.replace(/^\s+|\s+$/g,""); eval=eval.replace(/\s{2,}/g," "); document.getElementById("addr").value=eval; if(elem.value.replace(elem.value)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkcountry(elem,helpmg) { if(elem.value=="Please select country"){ alert(helpmg); elem.focus(); return false; } return true; } function Checkzip(elem,helpmg) { var zReExp=/^\d{5}$/; if(elem.value.match(zReExp)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkph(elem,helpmg) { var pReExp=/^\d{14}$/; if(elem.value.match(pReExp)){ return true; } else{ alert(helpmg); elem.focus(); return false; }} function Checkeduca(elem,helpmg) { if(elem.value=="Please choose"){ alert(helpmg); elem.focus(); return false; } return true; } function Checkjob(elem,helpmg) { if(elem.value=="Please select job"){ alert(helpmg); elem.focus(); return false; } return true; } function Checkhours(elem,helpmg) { if(elem.value=="Please select hours"){ alert(helpmg); elem.focus(); return false; } return true; } </script> <style type="text/css"> #fullpage{width:100%;background-color:#f3f3f3; border:1px solid #336699;} #firstbar{ width:100%; background-color:#336699; text-align:left; font-color:white; } #field{ margin-right:70%;text-align:right;} </style> </head> <body> <h2><font color=#336699>Form validation..The power of javascript<font></h2> <p><font clor=#336699>Please note:all the field marked asteric is required and must be field.<br/>For help on filling the form just contact as at support@jobs.com.<font></p> <hr width="100%" color="#336699" size="2"> <div id="fullpage"> <form onsubmit="return formvalidator()"/> <div id="firstbar"><p><font color="white">Personal Details</font></p></div> <div id="field"> <p><font color=red>*</font>Full Name<input type="text" id="Fullname"/></p> <p><font color=red>*</font>Email<input type="text" id="email"/></p> <p><font color=red>*</font>Contact Address<input type="text" id="addr"/></p> <p><font color=red>*</font>Country<select id="country"/> <option>Please select country</option> <option>Ghana</option> <option>United States</option> <option>India</option> <option>Germany</option> <option>Italy</option> <option>Nigeria</option> <option>South Africa</option> <option>United kingdom</option> <option>Malasia</option> <option>Egypt</option> <option>France</option> <option>China</option> </select></p> <p><font color=red>*</font>Zip Code<input type="text" id="zip"/></p> <p><font color=red>*</font>Phone Number<input type="text" id="phone"/></p> <p>Fax Number<input type="text" name="fax"/></p> </div> <div id="firstbar"><p><font color="white">Educational Details & Job</font></p></div> <div id="field"> <p><font color=red>*</font>Education Status<select id="educa"/> <option>Please choose</option> <option>High School</option> <option>Diploma</option> <option>Degree</option> <option>Certified We Developer</option> <option>Certified We Designer</option> <option>others</option> </select></p> <p>Experience(Details if any)<input type="text" name="exp"/></p> <p><font color=red>*</font>Job Type<select id="job"/> <option>Please select job</option> <option>We Developer</option> <option>Web Designer</option> <option>Softwar Developer</option> <option>IT Consultancy</option> <option>Stock Trader</option> <option>Marketing Position</option> </select></p> <p><font color=red>*</font>Working Hours<select id="hours"/> <option>Please select hours</option> <option>1 to 5hurs</option> <option>1 to 8hurs</option> <option>1 to 10hurs</option> <option>1 to 12hurs</option> <option>1 to 13hurs</option> <option>1 to 15hurs</option> <option>1 to 20hurs</option> </select><p/> <p>Salary Demanded<input type="text" name="sala"/></p> <p>Comment(if any)<textarea name="text" rows="3" cols="40" wrap="virtual"/></textarea></p> <input type="submit" value="Submit Form"/> <input type="reset" value="Reset Form"/> </div></div> </form> </body> </html> Thanks.Clement Osei. 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> 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 hiiii, im new to javascripts . Can anyone help me to know that a javascript which is validating a phone number accepts only digits but if the text field is left empty it should accept the entry as an empty entry.... plz share knowledge u will be more knowledgeable 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. Hi, I am a newbie at XML and this issue is proving to be a tough nut to crack for me. My AJAX query returns me an XML response of the following structure for a query on "ind": <countries> <country> <name>India</name> <capital>New Delhi</capital> </country> <country> <name>Indonesia</name> <capital>Jakarta</capital> </country> </countries> How do I transform the XML response into a HTML layout? Particularly, how do I get down to the value at each node?How do I traverse the XML document using JS? Is this (using XML) better than JSON (other than the obvious platform-independence)? Which is better? Thanks! Hi all, I'm new to php, but managed to get a domail.php working. My form from my html website is sent by the php file to my email address. However, the php echoes a mailresult upon successful sending, but how can I let my website respond to this mailresult?? I'd like to go to a different page, when the mailresult==OK, so something in my html file like if($mailResult==OK){ //go to page saying, your mail has been sent! } OR I could change the "OK" to something more like "Thank you, your mail has been received" in the php file, because this text IS shown in my browser window. Then I would need to know how to make the layout of the window saying this fit my website layout, because now the text is just in a white plain frame.. Hope you guys can help me with either of those two options. Thanks a ton!! Jay Hello, Im just starting out with java script. I have written the following statement, and for some reason it does not follow up beyond the prompt command. As i type in yes or no - the screen empties. Id be happy if you could tell me where i had gone wrong. My guess its something about the syntax. <!DOCTYPE html> <html> <title>ex</title> <head> <script> var question1 = prompt("do you want to hear a story?"); if (question1 = "yes") {console.log ("once upon a time there was a dragon");} else { console.log ("Maybe listen to a little music?");} </script> </head> <body></body> </html> I have the following files in the same directory. I can get index.php displayed but when I enter anything and hit submit I cannot get the or die message to display. I have the files in the c:\xampp\htdocs\ folder and am using http://localhost/index.php from a browser. index.php: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Username</title> </head> <body> <form action="index.php" method="POST"> Username: <input type="text" name="username"><br> <!--input is text, variable is 'username'--> Password: <input type="password" name="password"> <!--input is password, a type of text, variable is password --> <input type="submit" value="Log in"> <!--input is submit, which is a button, and text on button will read 'Log in'--> </form> </body> </html> login.php: Code: <?php $username = $POST['username']; // setting php var '$username' to equal 'username' from the index.php page (POST method) $password = $POST['password']; if ($username&&$password) //are true { $connect = mysql_connect("localhost", "root", "") //creates connection to database, we're creating a var called or die ("Couldn't connect"); //'$connect' and now we have 3 var's. 'localhost' is the host. 'root' is the //username. mysql_select_db("phplogin") or die("Couldn't find db"); } else die("Please enter a username and a password!"); ?> I'm make a ajax call to a processing PHP file that echos either "success" or an "error message". When the success is returning, i want Jquery to recognize this and then redirect the browsers instead of displaying the success message. Here are some snippets. I can only seem to parse to a blank or null. Jquery code: Code: $.ajax({ type: "POST", url: "process.php", data: wfLoginPost(), success: function(msg){ alert(msg); // both below are either null or blank //var res = $(msg).find("span.response").text(); //var res = $(msg).find("span.response").html(); if(res == 'Success'){ window.location = 'http://www.google.com'; } } }); process.php PHP Code: if($qry[0]['pwd'] == $password){ echo "<span class='response'>Success</span>"; }else{ echo "<span class='response'>Username or password did not match</span>"; } Here is the contents of the msg response from the ajax post: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="css/reset.css"/> <link rel="stylesheet" type="text/css" href="css/960grid.css"/> <link rel="stylesheet" type="text/css" href="css/style.css"/> <link rel="stylesheet" type="text/css" href="css/statusmessageQ.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.statusmessageQ-0.5.js"></script> </head> <span class='response'>Success</span> |