js获取单选按钮选项
---------------------------------------------------------------------------------------
下面是form表单
<form method="post" name="form1">
<label><input type="radio" name="radio" value="1-10 岁">1-10 岁</label>
<label><input type="radio" name="radio" value="11 岁">11 岁</label>
<label><input type="radio" name="radio" value="12-120 岁">12-120 岁</label>
<input type="button" οnclick="ok()" value="测试选择值">
</form>
下面是js获取数据
<script language="javascript" type="text/javascript">
<!--
function ok()
{
var temp=document.getElementsByName("radio");
for (i=0;i<temp.length;i++){
//遍历Radio
if(temp[i].checked)
{alert("你选择了"+temp[i].value);
//获取Radio的值
document.form2.textfield.value="你选择了"+temp[i].value;
//传递给另外一个表单
}
}
}
-->
</script>
还想数据传递给另外一个表单
<form method="post" name="form2">
<input type="text" name="textfield">
</form>
参考资料
js:http://www.blueidea.com/tech/web/2006/3567_8.asp
form:http://www.netvtm.com/w3s/html/html-forms.html
转:http://www.jluvip.com/blog/article.asp?id=260
转载于:https://www.cnblogs.com/macoo/archive/2007/05/17/750647.html