Jump to content

Checking radio buttons


dweb

Recommended Posts

Hi all

 

I have a simple HTML form, but have around 250 radio buttons, which are all needed.

 

All the radio buttons have different "name" attributes.

 

How can I run a check to make sure at least one of the radio buttons has been selected? Is this possible without passing the "name" attribute?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/279840-checking-radio-buttons/
Share on other sites

How are you generating your form? You can always create an array of the names. Then loop through and check for them.

$radio_array=array("radio1","radio2","etc");
$selected=False;  
foreach($radio_array as $radio) { 
   if(isset($_REQUEST[$radio] && $_REQUEST['radio'])) { $selected=True; }
}

if($selected) { 
   // do whatever you need to do here.
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.