单选按钮组 事件的实现

 

代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script type="text/javascript" language="javascript">

function checks()
{
var radios=document.getElementsByName("radio1");
for(var i=0;i<radios.length;i++)
{
if(radios[i].checked==true)
{
alert(radios[i].value);
}
}
}

</script>

</head>

<body>
<input name="radio1" type="radio" value="1" onClick="checks()">
<input name="radio1" type="radio" value="2" onClick="checks()">




</body>
</html>

 

posted @ 2010-07-09 11:59  Sue_娜  阅读(374)  评论(0编辑  收藏  举报