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

Apache無法執行.htaccess?

Apache無法執行.hta...

pexelsphoto5 首先.htaccess是在Apache HTTP Server服務器架設下...

HTML5 影音手持裝置適應不良篇

HTML5 影音手持裝置適應...

這天下午跟客戶開完會... 客戶針對專案中手持裝置網站適應性做了需調整的說明..另外還包括影音檔播放...

關於資安防護

關於資安防護

一直以來我都不敢寫跟資安有關的文章..對我來說...資安一直是一個課題..XSS...CSRF......

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