asp+ajax能实现根据下拉列表值动态无刷新显示数据

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>asp+ajax能实现根据下拉列表值动态无刷新显示数据</title>
</head>

<body>
<selectid="bb">
<optionvalue="1">a</option>
<optionvalue="2">b</option>
</select>
<divid="cc"></div>
<scriptlanguage="javascript">
function_get(a){returndocument.getElementById?document.getElementById(a):null}
varrequest=false;
try{
request=newXMLHttpRequest();
}catch(trymicrosoft){
try{
request=newActiveXObject("Msxml2.XMLHTTP");
}catch(othermicrosoft){
try{
request=newActiveXObject("Microsoft.XMLHTTP");
}catch(failed){
request=false;
}
}
}
_get("bb").onchange=aaa;

functionaaa(b){
b=b||window.event;
vartarget=b.target||b.srcElement;
varvl=_get(target.id).options[_get(target.id).selectedIndex].value;
creatrequest("serch.asp?name="+vl+"")//这里可以写url和你所选的那个options的value比如"1.asp?id="+vl+""
}

functioncreatrequest(url){
//alert(url)
request.open("GET",url,false);
request.onreadystatechange=updatePage;
request.send(null);
}

functionupdatePage(){
if(request.readyState==4){
varxmlDoc=request.responseText;
_get("cc").innerHTML=xmlDoc
}
}
</script>

</body>
</html>

你可能感兴趣的:(JavaScript,Ajax,XHTML,Microsoft,asp)