Hi,

I m populating 2 select boxes country & city dynamically using ajax. All is working fine in mozilla &all but not in IE. but when i change country acc. to it city select box doesn't get populated in IE.

<td width="60%" align="right">Country : <?=PopulateSelect('country1',"SELECT * FROM tblname order by cname",1,"Country");?> City : <?=PopulateSelect('city1',"select cityid,cityname from city where countryid=1 order by cityname",0);?></td>

Any help in this matter will be highly appreciated.
Thanks in advance

Member Avatar for stbuchok

I see absolutely no JavaScript in the example above. Can you please show the code that is causing you issues. Also please show the error that you are getting.

I getting blank selectbox in IE. Error is
"UnKnown runtime error" in js file
Here is js file code

function Ajax_init() {
this.GetData= function (val,id,p,load)
{
	var ctrl=null;
	var d=new Date();
	var timestamp=d.getMinutes()+'_'+d.getSeconds()+'_'+d.getMilliseconds();
var xmlHttp=GetXmlHttpObject()

	if(p==null)
		p=1;
	if(load==null)
		load=1;	


if (xmlHttp==null)

  {

  alert ("Browser does not support HTTP Request")

  return

  } 
ctrl=document.getElementById(id);
if(load==1)
	ctrl.innerHTML="<img src='images/loading.gif' />";
xmlHttp.onreadystatechange=function() { HandleGetData(id,xmlHttp);  }
xmlHttp.open("GET", 'AjaxPage.php?q='+val+'&page='+p+'&order='+document.getElementById('hdnorder').value+'&timestamp='+timestamp, true)
xmlHttp.send(null);
}
}

function HandleGetData(div,xmlHttp)
{ 
	
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 
	  //  ctrl.innerHTML=xmlHttp.responseText;
	// alert(xmlHttp.responseText);
	  document.getElementById(div).innerHTML=xmlHttp.responseText
		//LoadWindow();
 } 

}


function HandleGetData()
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 
	
	    ctrl.innerHTML=xmlHttp.responseText;
		LoadWindow();
 } 

}

function GetXmlHttpObject()
{

var xmlHttp=null;

try

 {

 // Firefox, Opera 8.0+, Safari

 xmlHttp=new XMLHttpRequest();

 }

catch (e)

 {

 // Internet Explorer

 try

  {

  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

  }

 catch (e)

  {

  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

 }

return xmlHttp;

}

on line

document.getElementById(div).innerHTML=xmlHttp.responseText

but everything is working fine all browsers except IE.

Thanks

Member Avatar for stbuchok

What version of IE are you testing this against?

In any of the IE versions its not working but currently i m testing in IE8.

Thanks

Member Avatar for stbuchok

What is the values for the following:

alert(document.getElementById(div));
alert(document.getElementById(div).innerHTML);
alert(xmlHttp.responseText);

The output is
for:
alert(document.getElementById(div));
[objectHTMLDivElement]
for
alert(document.getElementById(div).innerHTML);
<img src='images/loading.gif' />

for:
alert(xmlHttp.responseText);
<select name="city" id="city1">
<option value="0">Toronto</option>
<option value="1">Athabasca</option>
</select>

When i m printing alert it gives me the select code in alert box, but in page "blank selectbox".

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.