用 JavaScript 檢查 Radio Button 是否已選
要用 JavaScript 來檢查同一組的 radio button 是否已選,可用以下方法:
if ((theForm.radiobutton[0].checked==false) && (theForm.radiobutton[1].checked==false) && (theForm.radiobutton[2].checked==false)) {
alert('此選項未選。');
return false;
}
也就是要將 radio button 視為陣列,來檢查它們 checked 是 true 或 false。
至於 checkbox 則是直接檢查 checkbox.checked,而在 PHP 裡則要直接讀出它的值,例如 $_REQUEST["checkbox"]。

0 Comments:
張貼留言
<< Home