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 利用phpmailer 寄信...

PHP 利用phpmaile...

一般來說其實PHP本身已經提供了Mail()函數可以使用,但由於一些令人不愉快的原因...我租用的V...

找對方法,開創自己的網路流量

找對方法,開創自己的網路流量...

前些天,Tim傳來了一個消息...http://classt...

如何使用javascript判斷身分證號跟居留證格式

如何使用javascript...

首先,我是把如何用javascript判斷字串中必須包含中英文的方式延伸~ 將每一個字轉換成 ASC...

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