<html>
<head>
<script src="selectcustomer.js"></script>
</head>
<body>
<form>
请选择一位客户:
<select name="customers" οnchange="showCustomer(this.value)">
<option value="ALFKI">Alfreds Futterkiste
<option value="NORTS ">North/South
<option value="WOLZA">Wolski Zajazd
</select>
</form>
<div id="txtHint"><b>客户信息将在此处列出。</b></div>
</body>
</html>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function showHint(str){
if(str.length==0){
document.getElementById("txtHint").innerHTML="";
return;
}
createXMLHttpRequest();
if(xmlHttp==null){
alert("你的浏览器不支持AJAX!");
return;
}
var url="gethint.jsp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged(){
if(xmlHttp.readyState==4){
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function showCustome(str){
createXMLHttpRequest();
var url="gethint.jsp";
url=url+"?p="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
</script>