事件不应该在radio上触发,而应该在select上,另外不能通过ID来直接引用一个对象,要用document.getElementById才可以,下面是正确的:<script type="text/javascript">
function setText() {
var obj1=document.getElementById("tt");
var obj2=document.getElementById("Msg1_TName");
obj1.value=obj2.value;
}
</script>
<select id="Msg1_TName" onchange="setText()">
<option value="001">sdfg</option>
<option value="002">sdfgr</option>
<option value="003">fgeg</option>
<option value="004">fgfe</option>
<option value="005">fge</option>
</select>
<table cellSpacing="0" cellPadding="0" width="50%" >
<tr>
<td Valign="top">
<form method="POST" target="_blank" action="/vote.asp">
<table cellSpacing="0" cellPadding="0" border="1" width="100%">
<tr><td align="center">教学态度</td></tr>
<tr><td>
<input type="text" id="tt" name="pp" value="aaa"><br>
<input type="radio" name="jxtd" value="5">很好<br>
<input type="radio" name="jxtd" value="2">较好<br>
<input type="radio" name="jxtd" value="0">一般<br>
<input type="radio" name="jxtd" value="-2">较差<br>
<input type="radio" name="jxtd" value="-5">很差<br>
</td></tr>
<tr><td align="center"><input type="submit" value="投票"></td></tr>
</table>
</form>
</td>
<tr>
</table>
function setText() {
var obj1=document.getElementById("tt");
var obj2=document.getElementById("Msg1_TName");
obj1.value=obj2.value;
}
</script>
<select id="Msg1_TName" onchange="setText()">
<option value="001">sdfg</option>
<option value="002">sdfgr</option>
<option value="003">fgeg</option>
<option value="004">fgfe</option>
<option value="005">fge</option>
</select>
<table cellSpacing="0" cellPadding="0" width="50%" >
<tr>
<td Valign="top">
<form method="POST" target="_blank" action="/vote.asp">
<table cellSpacing="0" cellPadding="0" border="1" width="100%">
<tr><td align="center">教学态度</td></tr>
<tr><td>
<input type="text" id="tt" name="pp" value="aaa"><br>
<input type="radio" name="jxtd" value="5">很好<br>
<input type="radio" name="jxtd" value="2">较好<br>
<input type="radio" name="jxtd" value="0">一般<br>
<input type="radio" name="jxtd" value="-2">较差<br>
<input type="radio" name="jxtd" value="-5">很差<br>
</td></tr>
<tr><td align="center"><input type="submit" value="投票"></td></tr>
</table>
</form>
</td>
<tr>
</table>
解决方案 »
- javascript中的“方法”过了一会就不等于自身了,怎么理解?
- ♠ 求扫盲,有用过jqgrid的朋友请进来 ♠
- object的click事件
- 救命啊:javascript頁面傳值問題
- 请教:下面的代码中如何使用setTimeout("hiddenDiv();",1000)来代替setTimeout("document.all.AdLayer.style.display = 'none';",5000);
- 为什么attachevent没有生效?
- 关于div定位的问题。求教如何利用js改写div的left值!
- **display的怪问题**
- 怎样能在选中一个checkbox时,使表单中的一些text框不可用
- vue 组件父向子绑定传输数据问题
- 寻JS高手,
- location.assign 这个方法是什么意思?????
function setText() {
tt.value= Msg1_TName.value;
}
</script><script type="text/javascript">
function setText() {
document.getElementById('tt').value= Msg1_TName.options[Msg1_TName.selectedIndex].value;
}
</script>
<form runat="server">
<table cellSpacing="0" cellPadding="0" width="100%" height ="72%">
<tr>
<td vAlign="top"><PhyEws:Msg id="Msg1" runat="server"></PhyEws:Msg></td>
</tr>
</table>
<PhyEws:FOOTER id="Footer1" runat="server"></PhyEws:FOOTER>
真正的数据都在这里面生成了,我没有办法,只能把这些都放到表格中去,也就是有人点击投票RADIO时,才把真正给哪个人投票的编号写到隐藏域中去提交给我自己的页面