dweb Posted July 3, 2013 Share Posted July 3, 2013 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 More sharing options...
taquitosensei Posted July 3, 2013 Share Posted July 3, 2013 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. } Link to comment https://forums.phpfreaks.com/topic/279840-checking-radio-buttons/#findComment-1439336 Share on other sites More sharing options...
dweb Posted July 3, 2013 Author Share Posted July 3, 2013 worked a treat, thanks Link to comment https://forums.phpfreaks.com/topic/279840-checking-radio-buttons/#findComment-1439348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.