`
jickcai
  • 浏览: 239673 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

radio 如何取表单radio的值

 
阅读更多
例:
一切尽在不言中:
for (i=0;i<document.searchform.searchradio.length;i++) {
if (document.searchform.searchradio[i].checked) {
id = document.searchform.searchradio[i].value;
break;
}
}

---------------------------------------------------------------
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script>
function searchSubmit(){
var id;
for (i=0;i<document.searchform.searchradio.length;i++) {
if (document.searchform.searchradio[i].checked) {
id = document.searchform.searchradio[i].value;
break;
}
}
alert(id);//radio的值
var searchword=document.searchform.searchword.value;//searchword的值
alert(searchword);

return false;
}
</script>
<form id="searchform" onsubmit="return searchSubmit();" target="_blank" method="get" action="#" name="searchform">
<input id="searchword" type="text" name="searchword"/>
<input type="radio" value="视频" name="searchradio"/>
视频
<input type="radio" checked="" value="网页" name="searchradio"/>
网页
<input type="submit" value="提交" name="btnG"/>
</form>
</body>
</html>
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics