對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