function getCheckedRadioNum() { for (var i=0;i<document.form.userName.length;i++) if (document.form.userName[i].checked==1) return i; else return -1; }
谢谢meizz(梅花雨),你提供的程序能运行,可是我想响应radio的点击事件,我根据你提供的程序作了修改,可还是不行,不知道radio控件响不响应onclick 事件,请帮我把程序改正确,谢谢!: <html> <head> <title>hello</title> <script language="vbscript"> function checkme() for each ob in UseName { if ob.checked then alert("hello"); else alert("you are welcome"); } next end function </script> <body> <input type=radio name=UserName value=0 onclick="checkme()"> <input type=radio name=UserName value=1> </body> </head> </html>
应该是
if (document.form.Username[0].checked=="true"){
}
这个的话应该是
if (document.all.Username[0].checked=="true"){
}
<head>
<title>hello</title>
<body>
<input type=radio name=UserName value=0 onclick="onchange();">
<input type=radio name=UserName value=1>
</form>
</body>
</head>
</html>
<script>
function onchange()
{
if(document.UserName.value==0)
alert("hello");
else
alert("you are welcome");
}
</script>
这个程序是有两个radio,选第一个出"hello",选第二个出"you are welcome",但运行有错误,望高手赐教!
{
for (var i=0;i<document.form.userName.length;i++)
if (document.form.userName[i].checked==1)
return i;
else
return -1;
}
事件,请帮我把程序改正确,谢谢!:
<html>
<head>
<title>hello</title>
<script language="vbscript">
function checkme()
for each ob in UseName
{
if ob.checked then
alert("hello");
else
alert("you are welcome");
}
next
end function
</script>
<body>
<input type=radio name=UserName value=0 onclick="checkme()">
<input type=radio name=UserName value=1>
</body>
</head>
</html>
<script>
function ck()
{document.form1.checkbox[0].click();
document.form1.checkbox[2].click(); }
</script>
<body>
<form name=form1>
<input type=checkbox name=checkbox onclick="alert('34');">
<input type=checkbox name=checkbox >
<input type=checkbox name=checkbox onclick="alert('34');"><input type=button onclick=ck();>
</form>
</body>
</html>