asp单选按钮值的获取
物件找不到此屬性或方法Document.TestOdForm.BGAradio.checked
BGAradio 為單選按鈕
<span style="background-color: #FFD7C4"><font face="新細明體" size="2">客戶要求電測(BGA):是</font></span><input type="radio" style="background-color: rgb(241,254,224)" value="Y"
<%If not rs.EOF Then
If Trim(rs("BGAradio").value)="Y" Then
Response.Write "checked"
Else Response.Write ""
End If
End If%> name="BGAradio"><span style="background-color: #FFD7C4">否<input type="radio" style="background-color: rgb(241,254,224)" value="N"
<%If not rs.EOF Then
If Trim(rs("BGAradio").value)="N" Then
Response.Write "checked"
Else Response.Write ""
End If
End If%> name="BGAradio"></p> </span>
我想取得这个值,一个为Y或者一个为N,如果为空系统跳出防呆。。。谢谢!!
------解决方案--------------------
Document.TestOdForm.BGAradio不是一个input
用 document.getElementsByName("BGAradio") 获取两个radio进行遍历就行了
示例代码(可复制为htm文件运行):
<html>
<head>
<script type="text/javascript">
function doclick(){
var id = document.getElementsByName("test");
for(var i=0;i<id.length; i++){
var radio=id[i];
alert(radio.value + radio.checked);
}
}
</script>
</head>
<body>
<input type="radio" id="test" name="test" value="test 1" > test 1
<input type="radio" id="test" name="test" value="test 2"> test 2
<br>
<input type="button" id="btn" value = "Select" onclick="doclick();">
</body>
</html>