Loading...

JavaScript 檢查 Radio Button

Temperature: 0 °C

ChungChung
author_tools

要用 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"]

https://innstory.com/story-JavaScript_檢查_Radio_Button-140
寫程式筆記

Prev
 sql檔過大無法匯入phpMyAdmin

Next
SQL_Injection 

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

客語檢定

客語檢定

恭喜通過客語基礎檢定,期待你將來可以直接用客語跟我對話。

IE10 在 fckeditor無正常顯示及無法輸入任何字元

IE10 在 fckedit...

於fckorcodeie.js 檔案中, 在B.open(‘GET’, A, false); 及 B...

jQuery效果滑動隱藏

jQuery效果滑動隱藏

因為需要所以紀錄下來,主要是要透過點選按鈕將字串隱藏或顯示出來... 雖說可以直接用hide或是sh...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format