adamjblakey Posted April 7, 2008 Share Posted April 7, 2008 Hi, I have this function here: var AdminResponse = ""; function parseResponse(){ var nText = AdminResponse.getElementsByTagName('optionText'); var nVal = AdminResponse.getElementsByTagName('optionVal'); document.forms[0]['region'].options.length = 1; for (i=0; i<nText.length; i++) { var nOption = document.createElement('option'); var isText = document.createTextNode(nText[i].firstChild.data); nOption.setAttribute('value',nVal[i].firstChild.data); nOption.appendChild(isText); document.forms[0]['region'].appendChild(nOption); } } function update(nVal){ var AdminRequest = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); AdminRequest.onreadystatechange = function() { if (AdminRequest.readyState == 4) { if (AdminRequest.status == 200) { AdminResponse = AdminRequest.responseXML; parseResponse(); } else { alert('Error Update.php File '+ AdminRequest.statusText); } } } var infoStr = "?choice="+nVal; AdminRequest.open("GET", "Update.php"+infoStr, true); AdminRequest.send(null); } What this does is when i select a region from a list it dynamically fills the town list with the relevant towns. My problem is that i have 3 fields for regions and 3 towns so i need to replicate this function 3 times but don't know which bits to change. Please can someone help me out. Adam Link to comment https://forums.phpfreaks.com/topic/99935-ajax-dropdown-menus/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.