Hi,
I am having problem with applying ajax on IE.I am applying innerHtml on select tag but it is not working my ajax code is

function AjaxF(ftype,cid)
{

var httpxml;
try
  {
  // Firefox, Opera 8.0+, Safari
  httpxml=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
          try
                        {
                    httpxml=new ActiveXObject("Msxml2.XMLHTTP");
                    }
              catch (e)
                    {
                try
              {
              httpxml=new ActiveXObject("Microsoft.XMLHTTP");
              }
                catch (e)
              {
              alert("Your browser does not support AJAX!");
              return false;
              }
            }
  }
function stateck()
    {
    if(httpxml.readyState==4)
      {

var myarray=httpxml.responseText;
if(ftype=='Files')
{
document.getElementById('temp_thumbnail').innerHTML = myarray;
document.getElementById('temp_mainfiles').innerHTML = myarray;
document.getElementById('temp_preview').innerHTML = myarray;
document.getElementById('temp_image').innerHTML = myarray;
}
else 
{
document.getElementById('temp_thumbnail').innerHTML = myarray;
document.getElementById('temp_main').innerHTML = myarray;
document.getElementById('temp_image').innerHTML = myarray;
}


      }
    }
var url="ajax/files_ajax.php";	
url=url+"?filetype="+ftype+"&customerid="+cid;
url=url+"&sid="+Math.random();
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
  }

My php code for creating option is.I am getting the values in filetype and it is working fine on other browsers

$sql="select name ,id from temporary_upload where type ='$filetype' AND customer_id='$customer_id'";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result))
	{

    
	$s.="<option id='' name='' selected='selected' value='". $rows['name']  ."'>".  $rows['name'] ."</option>";
	
}

echo $s;

My html for this code is

<select id="temp_thumbnail" name="temp_thumbnail" style="width:452px">

                <option></option>
                
              </select>

I have searched for this error on many forums.They all are saying that innerHtml with select has error in IE can anyone help me to resolve this issue.That I can populate my select option.
Thanks in advance

Saadi,

The simplest solution is to replace the entire menu from <select ...> to </select>. You can either build the menu like this in php or "top and tail" the options string in the ajax success handler.

If you don't already have an addressable container, then wrap the original menu in <span id="...">...</span>.

If you have an onchange handler ('change' in jQuery), then you need to attach it with .live('change', ...) otherwise its action will be lost when the element is replaced.

Airshow

Thanks airshow I have solved the problem.I replaced the whole select portion and it worked fine.Thanks a lot

Fantastic Saadi.

There's a "... solved" link toward the bottom of the page.

Airshow

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.