select内容动态变化
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function testFun()
{
var o = document.getElementById("test2");
for (var i = 0; i < o.options.length; i++) {
if (o.options[i].value == document.getElementById("test1").value) {
o.options[i].selected = true;
}
}
}
//-->
</SCRIPT>
</head>
<body>
<select name="test1" onchange="testFun()" id="test1">
<option value ="listKey1">listKey1</option>
<option value ="listKey2">listKey2</option>
<option value="listKey3">listKey3</option>
<option value="listKey4">listKey4</option>
</select>
<select name="test2" id="test2">
<option value ="listKey1">listValue1</option>
<option value ="listKey2">listValue2</option>
<option value="listKey3">listValue3</option>
<option value="listKey4">listValue4</option>
<option value ="listKey5">listKey1</option>
</select>
<input type="button" value="test" onclick="testFun()"/>
</body>
</html>