<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<script>
<!--
//选中2返回的也是1,找到第一个ID为该值的DOM,弹出 1
function getVById(){alert(document.getElementById('test11').value);}
function getVByName(){
var tt = document.getElementsByName('test11');
for (var iIndex = 0; iIndex < tt.length ; iIndex++ )
{
if(tt[iIndex].checked)
{
alert(tt[iIndex].value);
break;
}
}
};
-->
</script>
</head>
<body>
<input type="radio" id="test11" name="test11" value="1" />测试1
<input type="radio" id="test11" name="test11" value="2" />测试2
<input type="button" value="BTN_ByID" onclick="getVById()" />
<input type="button" value="BTN_ByName" onclick="getVByName()" />
</body>
<html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<script>
<!--
//选中2返回的也是1,找到第一个ID为该值的DOM,弹出 1
function getVById(){alert(document.getElementById('test11').value);}
function getVByName(){
var tt = document.getElementsByName('test11');
for (var iIndex = 0; iIndex < tt.length ; iIndex++ )
{
if(tt[iIndex].checked)
{
alert(tt[iIndex].value);
break;
}
}
};
-->
</script>
</head>
<body>
<input type="radio" id="test11" name="test11" value="1" />测试1
<input type="radio" id="test11" name="test11" value="2" />测试2
<input type="button" value="BTN_ByID" onclick="getVById()" />
<input type="button" value="BTN_ByName" onclick="getVByName()" />
</body>
<html>