Javascript 如何得到input type="radio" 的值?
2008-06-25 11:49
531 查看
<script language="JavaScript">
<!--
function chk()
{
var obj = document.getElementsByName('imgposition');
for (i=0;i<obj.length;i++)
{
if (obj[i].checked)
{
alert(obj[i].value);
return;
}
}
alert('你没选');
}
//-->
</script>
<form name=form1>
<input type="radio" name="imgposition" value="1">
<input type="radio" name="imgposition" value="2">
<input type="radio" name="imgposition" value="3">
</form>
<input type="button" onclick="chk()">
for example:
<INPUT type=radio name="radio" CHECKED>1-10 years old
<INPUT type=radio name="radio">11 years old
<INPUT type=radio name="radio">12-120 years old
This example uses script to detect which radio button the user selects.
<SCRIPT>
function detect()
{
if (radio[0].checked)
alert("You're between 1 and 10 years old.")
else if (radio[1].checked)
alert("You're 11 years old.")
else
alert("You're between 12 and 120 years old.")
}
</SCRIPT>
alimama_pid="mm_10031633_430368_2563168";
alimama_titlecolor="0000FF";
alimama_descolor ="000000";
alimama_bgcolor="FFFFFF";
alimama_bordercolor="E6E6E6";
alimama_linkcolor="008000";
alimama_bottomcolor="FFFFFF";
alimama_anglesize="0";
alimama_bgpic="0";
alimama_icon="0";
alimama_sizecode="12";
alimama_width=468;
alimama_height=60;
alimama_type=2;
<!--
function chk()
{
var obj = document.getElementsByName('imgposition');
for (i=0;i<obj.length;i++)
{
if (obj[i].checked)
{
alert(obj[i].value);
return;
}
}
alert('你没选');
}
//-->
</script>
<form name=form1>
<input type="radio" name="imgposition" value="1">
<input type="radio" name="imgposition" value="2">
<input type="radio" name="imgposition" value="3">
</form>
<input type="button" onclick="chk()">
for example:
<INPUT type=radio name="radio" CHECKED>1-10 years old
<INPUT type=radio name="radio">11 years old
<INPUT type=radio name="radio">12-120 years old
This example uses script to detect which radio button the user selects.
<SCRIPT>
function detect()
{
if (radio[0].checked)
alert("You're between 1 and 10 years old.")
else if (radio[1].checked)
alert("You're 11 years old.")
else
alert("You're between 12 and 120 years old.")
}
</SCRIPT>
alimama_pid="mm_10031633_430368_2563168";
alimama_titlecolor="0000FF";
alimama_descolor ="000000";
alimama_bgcolor="FFFFFF";
alimama_bordercolor="E6E6E6";
alimama_linkcolor="008000";
alimama_bottomcolor="FFFFFF";
alimama_anglesize="0";
alimama_bgpic="0";
alimama_icon="0";
alimama_sizecode="12";
alimama_width=468;
alimama_height=60;
alimama_type=2;
相关文章推荐
- Javascript 如何得到input type="radio" 的值?
- javascript 如何得到input type="radio" 的值?
- 如何点击文字,把input type="radio" 或者 input type="checkbox" 也选中
- HTML中INPUT type="date"标签如何赋值注意问题
- 通过javascript获取<input type="file">的客户端真实路径
- <input type="file"/>如何获取判断获取文件后缀
- 如何给input type="password"的输入框赋默认值?
- html 如何使input type = "image" 不提交表单
- jQuery操作<input type="radio">
- jQuery设置input type="radio" 哪个值为被选中的
- 如何改变<input type=”text" >输入框内的值
- struts2 <input type="radio" 默认选中
- 如何更改 iOS 和安卓浏览器上的 input[type="radio"] 元素的默认样式?
- 如何改变<input type=”text" >输入框内的值
- jQuery操作<input type="radio">
- jQuery操作radiojQuery操作<input type="radio">
- Angular2 type="radio" 如何得到值
- <input type="text" 鼠标移动去清空默认value onclick=javascript:this.value=''
- button & input type="button"
- 让HTML中的文本框<input type="text">中的文字垂直居中