插入式下拉菜单和隐藏文本框的值互动? <SELECT NAME="select">
<OPTION VALUE="hao1:50000">1</OPTION>
<OPTION VALUE="hao2:80000">2</OPTION></SELECT>
<INPUT TYPE=hidden STYLE="WIDTH: 90px"
VALUE="???" NAME=type> 我想做到:当点插入式下拉菜单 1时,下面的隐藏值是 50000
反之点2时,隐藏值是 80000 如何用javascript实现?
请高手试调一下写出完整代码!!!
<OPTION VALUE="hao1:50000">1</OPTION>
<OPTION VALUE="hao2:80000">2</OPTION></SELECT>
<INPUT TYPE=hidden STYLE="WIDTH: 90px"
VALUE="???" NAME=type> 我想做到:当点插入式下拉菜单 1时,下面的隐藏值是 50000
反之点2时,隐藏值是 80000 如何用javascript实现?
请高手试调一下写出完整代码!!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<script type="text/javascript">
<!--
window.onload = function(){
document.getElementById("obtn").value = osel.options[osel.selectedIndex].value.split(":")[1];
}
function ShowValue(osel){
document.getElementById("obtn").value = osel.options[osel.selectedIndex].value.split(":")[1];
}
//-->
</script>
</head> <body>
<select id="osel" onchange="ShowValue(this);">
<option value="hao1:50000" selected="selected" >1</option>
<option value="hao2:80000">2</option>
</select>
<input type="button" value="" id="obtn" />
</body>
</html>为了演示 用得button 你自己将type="hidden"
dd=request("button")
response.write dd
%><SCRIPT TYPE="text/javascript">
<!--
window.onload = function(){
document.getElementById("obtn").value = osel.options[osel.selectedIndex].value.split(":")[1];
}
function ShowValue(osel){
document.getElementById("obtn").value = osel.options[osel.selectedIndex].value.split(":")[1];
}
//-->
</SCRIPT>
<FORM METHOD="post" ACTION=""><SELECT ID="osel" ONCHANGE="ShowValue(this);" NAME="select">
<OPTION VALUE="hao1:50000" selected >1</OPTION>
<OPTION VALUE="hao2:80000">2</OPTION>
</SELECT> <INPUT TYPE="button" VALUE="" ID="obtn" NAME="button" >
<INPUT TYPE="submit" NAME="Submit" VALUE="Submit">
</FORM>