Jump to content

Need help with this..


adamjblakey

Recommended Posts

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 replicate this another 2 times.

 

Thank you in advanced.

Adam

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.