emjez15 Posted January 29, 2011 Share Posted January 29, 2011 :(This is my Ajax Function for my select list Year Level to change what is in the database.. xmlhttp4.onreadystatechange=function() { var lol1; var lol2; var fir; var sec; //document.form1.yearlvl.selectedIndex = 3; if(xmlhttp4.readyState==4 && xmlhttp4.status==200) { sec = xmlhttp4.responseText; lol1 = sec.replace("\n", ""); switch(lol1) { case "1st": document.form1.yearlvl.selectedIndex = 1; break; case "2nd": document.form1.yearlvl.selectedIndex = 2; break; case "3rd": document.form1.yearlvl.selectedIndex = 3; break; case "4th": document.form1.yearlvl.selectedIndex = 4; break; } } } And This is my Select List in HTML <select name = yearlvl id = yearlvl> <option>Choose Year Level</option> <option value = "1st">1st Year</option> <option value = "2nd">2nd Year</option> <option value = "3rd">3rd Year</option> <option value = "4th">4th Year</option> </select> I don't know why it doesn't seem to work T___T Thanks for any help -EM Quote Link to comment https://forums.phpfreaks.com/topic/226030-ajax-function-not-working/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.