Jump to content

working in firefox but not in ie 6/7??


LoOpy

Recommended Posts

ok now this script below is dynamicaly changing the option for the select its working perfectly in firefox 2 but not in ie 6 or 7 which sux am i missing a setting in ie or do i need to change the script??

 

this script abit dirty but im new to ajax so any simplification would be welcome.

 

hope everything clear....

 

select 1

<select id="source" name="source" onChange="sourceSelect(this.options[this.selectedIndex].value);">
<option> Select </option>
<option >Online</option>
<option >Print</option>
<option >Video</option>
</select>

select 2

<select name="sourceType" id="sourceType" />
<option> Empty </option>
</select>

 

function

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;
}
var xmlHttp=null;
}

function sourceSelect(selectedValue){
	var typeArray = ''; 
	var x = Array(); //gen array
	var v = ''; //var
	document.getElementById('sourceType').options.length = 0;
	var req = getHTTPObject();	
	req.open('GET', 'includes/ajax.php?name='+selectedValue, true);
	req.onreadystatechange = function (aEvt) {
		if (req.readyState == 4) {
			typeArray = req.responseText;
			x = typeArray.split(',');
			for (v in x){
				document.getElementById('sourceType').options[v] = new Option(x[v],x[v]);
			}	
		}			
	};		
	req.send(null);
}var req = null;

 

ajax.php queries database which returns string to function

echo 'Select,opj1,obj2,obj3';

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.