日期:2014-05-16 浏览次数:20728 次
<script>
function ajax(){
val = document.getElementById("Sort_One").value
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("SortOne").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax.asp?t="+Math.random()+"&val="+val,true);
xmlhttp.send();
//xmlhttp.open("POST","ajax.asp",true)
//xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
//xmlhttp.send("val="+val+"&t="+Math.random());
}
</script>
val = request("val")
sortone_sql = "select * from Phone_SortOne where Content_Sort_ID="&val
set query_SortOne = Conn.execute("select * from Phone_SortOne where Content_Sort_ID="&val)
while not query_SortOne.eof
response.write "<option>"&query_SortOne("Content_SortOne_Name")&"</option>"
query_SortOne.movenext
wend
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
<style>
</style>
</head>
<body>
<select id="test"></select>
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
$('test').innerHTML = '<option>1</option>'
</script>
</body>
</html>
------解决方案--------------------
这是IE 的一个BUG,微软的BUG申明中注明了两种解决方案:
1. 如果您必须使用 innerHTML ,一种替代方法是使用一个 div 对象封装 SELECT 元素和然后设置 div 对象的 innerHTML 属性。
如:
<div id="div1">
<select id="sel1" ></select>
</div>
<script>
window.onload=function(){
document.getElementById("div1").innerHTML="<select id='sel1'><option>a</option></select>";
}
</script>
2、使用new Option()对象,然后添加到下拉框控件中。
推荐使用这种。
------解决方案--------------------
兼容问题 汗~
1楼说的好!