<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/ 1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>网页特效 asp.net教程判断单选按钮是否被选中几种方法</title>
<script language="网页特效">
function yanzheng(){
var thecheckboxinputs=document.getelementsbyname('gender');
for(var i=0;i<thecheckboxinputs.length;i++)
{
if(thecheckboxinputs[i].checked)
return true;
}
alert('您还没有选中其中的一项');
return false;
}
</script></head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="radio" name="gender" id="radio" value="radio" />男
</label>
<label>
<input type="radio" name="gender" id="radio2" value="radio2" />女
</label>
<label>
<input type="submit" name="submit" value="提交" onclick="return yanzheng();"/>
</label>
</form>
</body>
</html>
//asp.net
this.radiobuttonlist.items[0].selected==true;
//
<script>
function check()
{
for(i=0;i <document.form1.r1.length;i++)
if(document.form1.r1[i].checked)
{alert(document.form1.r1[i].value);return;}
}
</script><form name=form1>
<input type=radio name=r1 value=1>
<input type=radio name=r1 value=2>
<input type=radio name=r1 value=3>
<input type=button onclick=check()>
</form>