digetydog Posted September 20, 2013 Share Posted September 20, 2013 Hi, newbie here (to complicated php) Trying to deselect 2 different radio button groups when a single third one is clicked; Here is the code I have: <?php radio($data, 'educationsessions', 'Infrastructure Asset Management Simplified'); ?><br /> <?php radio($data, 'educationsessions', 'Create, attract and maintain a strong and thriving business community'); ?><br /> <?php radio($data, 'educationsessions', 'Balancing the Municipal Books'); ?><br /> <?php radio($data, 'educationsessions', 'Managing to Have Fun: Laughing Matters!'); ?><br /> <?php radio($data, 'educationsessions', 'The AUMA & AMSC Business Services'); ?><br /> <?php radio($data, 'educationsessions', 'LGAA: The Brand: Harmonizing Identify and Destiny in Communities'); ?><br /> <?php radio($data, 'educationsessions', 'Council Obligations'); ?><br /> <?php radio($data, 'educationsessions2', 'Connecting with Your Community', 'Connecting with Your Community: Leveraging New Media'); ?><br /> <?php radio($data, 'educationsessions2', 'Participating in Canada\'s Political Landscape'); ?><br /> <?php radio($data, 'educationsessions2', 'Building Consensus, Achieving Results'); ?><br /> <?php radio($data, 'educationsessions2', 'Advancing Sustainability in Your Community'); ?><br /> <?php radio($data, 'educationsessions2', 'Addressing the Affordable Housing Challenge'); ?><br /> <?php radio($data, 'educationsessions2', 'Meeting Transportation Needs in Your Community'); ?><br /> <br> <strong>Special Extended Session 1:45 pm 4:00pm</strong><br> <?php radio($data, 'educationsessions3', 'The Future of Municipal Government: Inspiring the Evolution'); ?> AND the function function radio($data, $name, $value, $value2 = false, $attrs){ $curval = $data[$name]; $h = ""; if($attrs && count($attrs)){ foreach($attrs as $key => $attr){ $h .="".$key."=\"".$attr."\" "; } } echo "<label><input ".$h." ".($curval==$value ? 'checked':'')." type='radio' name='".$name."' value='".$value."'> ".($value2 ? $value2 : $value)."</label>"; } any help would be awesome Quote Link to comment https://forums.phpfreaks.com/topic/282322-php-radio-buttons-2-groups-need-to-clear-both-on-select/ Share on other sites More sharing options...
requinix Posted September 20, 2013 Share Posted September 20, 2013 So of all those options only one is allowed? Name them all the same - like "educationsessions" instead of "educationsessionsN". Quote Link to comment https://forums.phpfreaks.com/topic/282322-php-radio-buttons-2-groups-need-to-clear-both-on-select/#findComment-1450455 Share on other sites More sharing options...
digetydog Posted September 20, 2013 Author Share Posted September 20, 2013 Hi Sleepy, Actually they can select 1 from the first group and one from the second group. If they choose the third then I need to clear the first two. first group is a morning session 2nd is afternoon 3rd is full day. Quote Link to comment https://forums.phpfreaks.com/topic/282322-php-radio-buttons-2-groups-need-to-clear-both-on-select/#findComment-1450497 Share on other sites More sharing options...
requinix Posted September 21, 2013 Share Posted September 21, 2013 (edited) Then 1. Write some PHP (where you process the form) that validates them having only selected ones from the first two or one from the third. 2. Write some Javascript that will automatically deselect all from the first two groups if any from the third group is selected; also deselect all from the third if any in the first two are selected. Moved from Coding Help. Are you using a Javascript framework? Which? [edit] And what does the outputted HTML look like? Edited September 21, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/282322-php-radio-buttons-2-groups-need-to-clear-both-on-select/#findComment-1450507 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.