上合会议2015郑州:vbscript中多个radiobutton控件如何实现单选?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/06 04:14:15
我在一个表单中加入了两个radiobutton控件,但是在选择时,两个radiobutton总是都有小黑点,怎么办?
比如说这段代码:
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="frm1" method="post" action="">
<p>
<input type="radio" name="radiobutton1" value="radiobutton" checked>
a</p>
<p>
<input type="radio" name="radiobutton2" value="radiobutton">
b</p>
<p>
<input type="text" name="textfield">
</p>
<input type="button" name="button1" value="按钮">
<script language="vbscript">
sub button1_onclick()
if document.frm1.radiobutton1.checked then frm1.textfield.value="a"
if document.frm1.radiobutton2.checked then frm1.textfield.value="b"
end sub
</script>
</form>
</body>
</html>
怎么办?急!

<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="frm1" method="post" action="">
<p>
<input type="radio" name="radiobutton" value="radiobutton" id="r1" checked>
a</p>
<p>
<input type="radio" name="radiobutton" value="radiobutton" id="r2">
b</p>
<p>
<input type="text" name="textfield">
</p>
<input type="button" name="button1" value="按钮">
<script language="vbscript">
sub button1_onclick()
if document.frm1.r1.checked then frm1.textfield.value="a"
if document.frm1.r2.checked then frm1.textfield.value="b"
end sub
</script>
</form>
</body>
</html>

OK了,自己记得看看html的name和id的区别。