select控件和input控件联动的问题
要求简单,
就是把select中选择的值现实在input文本框中
html代码
<form name= " ">
<input name= "y "> </input>
<div id= "y "> test </div>
<select name= "X ">
<option selected> teSt# </option>
</select>
</form>
------解决方案-------------------- <html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
<script language= "javascript " type= "text/javascript ">
<!--
function setvalue()
{
var txt = document.getElementById( "testtext ");
var sel = document.getElementById( "sel ");
txt.value = sel.options[sel.selectedIndex].text;
}
-->
</script>
</head>
<body>
<form id= "form1 " runat= "server " action= "Default2.aspx ">
<div>
<input type= "text " id= "testtext " />
<select id= "sel " onchange= "javascript:setvalue(); ">
<option value= "1 "> aaa </option>
<option value= "2 "> bbb </option>
<option value= "3 "> ccc </option>
</select>
</div>
</form>
</body>
</html>