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

PHP的日期時間相減方法之二

PHP的日期時間相減方法之二...

這幾天很忙...忙著寫客戶的系統.. 忙到沒時間亂開其他網站... 忙到沒時間去研究新東西... 忙...

ajax防止重複提交

ajax防止重複提交

會發生重提交的原因,大致上是因為考驗人與系統間的耐性~ AJAX(非同步的JavaScript與XM...

利用 css 讓 ul 置中呈現

利用 css 讓 ul 置中...

以前寫網站...總是喜歡用Table 包住內容.. 而隨著時空的轉換...現在大都用div..或者....

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