js问题之单选框问题(程序纠错)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>编写JAVA脚本</title>
<script language="JavaScript">
function getSelected(bb)
{
for(var i=0;i<bb.length;i++)
{if(bb[i].checked) return i;}
return 0;
}
function checkok(ff)
{
var i=getSelected(ff.f1);
alert("你选择的作家是"+ff.r1[i].value);
}
</script>
</head>
<body>
<form>
<b>请选择你最喜欢的作家</b><p>
<input type="radio" name="r1" value="曹雪芹,作品是红楼梦" checked>曹雪芹
<input type="radio" name="r1" value="巴金,作品是春秋家">巴金
<br>
<input type="radio" name="r1" value="老舍,作品是骆驼详子">老舍
<input type="radio" name="r1" value="曹隅,作品是雷雨">曹隅
<br>
<input type="button" name="b1" onClick="checkok(this.form)" value="确认">
</form>
</body>
</html>