一个文本框输入内容后,其他文本框内容自动填写
比如我有5个文本框,
yname,yold,ydepartment,yaddress,ybemo
当yname文本框输入姓名后,自动从数据库中读取此姓名对应的内容,然后自动填写到四个文本框中。
谢谢!
------解决方案--------------------写的简练点,理解就行了
<script>
function createxmlhttp(){//创建对象
var xmlhttpobj=false;
try {xmlhttpobj = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e) {
try{xmlhttpobj = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e) {xmlhttpobj = false;}
}
if (!xmlhttpobj && typeof XMLHttpRequest!='undefined'){
xmlhttpobj = new XMLHttpRequest();
if (xmlhttpobj.overrideMimeType){
xmlhttpobj.overrideMimeType('text/xml');
}
}
return xmlhttpobj;
}
function aaa(t){
var xmlhttpobj = createxmlhttp();
if(xmlhttpobj){
xmlhttpobj.open('get',"bbb.asp?yname="+t+"&number="+Math.random(),true);
xmlhttpobj.send(null);
xmlhttpobj.onreadystatechange=function(){
if(xmlhttpobj.readystate==4){
if(xmlhttpobj.status==200){
var html = xmlhttpobj.responseText.split(",");
document.getElementById("yold").value = html[0];
document.getElementById("ydepartment").value = html[1];
}
}
}
}
}
<script>
<input name="yname" id="yname" onchange="aaa(this.value)">
<input name="yold" id="yold">
<input name="ydepartment" id="ydepartment">
===================================================
bbb.asp
获取到yname到数据库里查到结果返回就行了
response.Charset="GB2312"
response.write rs("yold")&","&rs("ydepartment")
你可以只写一个输出语句试一下,例如 response.write "aaa,bbb"
这样aaa就会赋值给yold输入框,bbb就会赋值给ydepartment输入框