对HTML很新颖,我想知道为什么这段代码不起作用?Html单选按钮
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div style="font-family: Consolas;">
<h1>This is a survey regarding *</h1>
<form name="firstQuestion" method="get" action="">
<input type="radio" name="q1" value="1" id="num1">I think its 1<br>
<input type="radio" name="q1" value="2" id="num2">I think its 2<br>
<input type="radio" name="q1" value="3" id="num3">I think its 3<br>
<input type="radio" name="q1" value="4" id="num4">I think its 4<br>
<input style="position: absolute; bottom: 10px; right: 10px" type="button" value="proceed" onclick="alert('Checked value is: '+getCheckedValue(document.forms['firstQuestion'].elements['q1']))">
</form>
</div>
</body>
问题是,当我按下继续按钮时,什么也没有发生,而它应该会返回所选的单选按钮,如您所见。
现在我还在,有没有人知道如何添加例如选项3和4之间的额外文本字段如果选择可能性3?默认为 ,如果未选择3,则文本框不应该可见。
getCheckedValue做什么? – craig1231