<script language=javascript>
document.frmname.username.value //可以得到select中选中的值,用它去userlist中查找就行了。
</script>
不过你的userlist是服务器端代码,可能的想办法把他存为客户端对象,才能在客户端js中查找了。
document.frmname.username.value //可以得到select中选中的值,用它去userlist中查找就行了。
</script>
不过你的userlist是服务器端代码,可能的想办法把他存为客户端对象,才能在客户端js中查找了。
function onSelect()
{
o=document.getElementById("username")
document.getElementById("useradd").value=""
document.getElementById("usereml").value=""if(o.options[o.selectedIndex].value!="0")
{
document.getElementById("useradd").value=o.options[o.selectedIndex].value
document.getElementById("usereml").value=o.options[o.selectedIndex].text
}
}
</script>
onSelect();
document.form1.submit();
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>New Page 2</title>
</head><body>
<form>
<select name="username" id="username" onchange="userChangeFun()" style="width:100px">
<option value="0" userAddress="" userEml="" > 请选择 </option>
<option value="1" userAddress="湖南" userEml="[email protected]" >张三</option>
<option value="2" userAddress="广东" userEml="[email protected]" >李四</option>
</select> <input name="useradd" type="text" id="useradd" >
<input name="usereml" type="text" id="usereml" >
</form>
<script >
function userChangeFun()
{
var currentOption=document.all.username.options[document.all.username.selectedIndex];
document.all.useradd.value=currentOption.userAddress;
document.all.usereml.value=currentOption.userEml;
}
</script>
</body></html>