radiobutton值传给textbox的问题
<script >
function abc() {
var obj = document.form1.getElementsByName("rd_id");
for(var i=0;i<obj.length;i++){
if(obj[i].checked){
document.form2.getElementById("txtID").value=obj[i].value;
return true;
}
}
}
</script>
</head>
<body>
<form id="form1" name="form1" action="" method="get">
<input type="radio" name="rd_id" value="1" onchange="abc();" /><br />
<input type="radio" name="rd_id" value="2" onchange="abc();" /><br />
<input type="radio" name="rd_id" value="3" onchange="abc();" /><br />
<input type="radio" name="rd_id" value="4" onchange="abc();" /><br />
</form>
<form id="form2" name="form2" method="post" action="">
<input name="txtID" id="txtID" type="text" />
</form>
</body>
我想要的结果就是哪个radiobutton被选中了,textbox就自动的添加该radiobutton的value值。
可是我这段代码运行了就是没反应,不知道哪边出错了,求高手帮忙!谢谢!
...全文
相关推荐
Asp.net的TextBox回车触发事件
当检测到回车键(`keyCode`值为13)并且`TextBox1`中的值非空时,会阻止默认的回车行为,并模拟一个Tab键事件。
RadioButton
TextBox控件用于显示用户选择的日期和时间。- GroupBox1(选择年月日)包含三个RadioButton:年份(rbtnYear)、月份(rbtnMonth)和日期(rbtnDay)。
C#清空界面控件值技巧
": parContainer.Controls[index].Text = ""; break; Case "RadioButton": ((RadioButton)(parContainer.Controls
常用控件的使用(Button、TextBox、ComboBox、ListBox等)
TextBox1.Text = "" TextBox2.Text = "" End IfEnd Sub```这段代码首先检查`TextBox1`和`TextBox2`中的文本是否与预设的用户名和密码匹配
演示C#的输入框、单选框控件的用法(源码)
在C#编程中,输入框(TextBox)和单选框(RadioButton)是常见的用户界面控件,用于收集用户的输入和提供选项选择。


