![]() |
How to save multiple radio boxes ??? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to save multiple radio boxes ??? (/showthread.php?tid=39129) |
How to save multiple radio boxes ??? - El Forum - 03-01-2011 [eluser]Bainzy[/eluser] Hey everyone, Being doing some work on Dove Forum and im currently adding in a ACL system based on a PHP5 ACL system that was posted on nettuts a while ago. Anyway I have converted it for use in a CI library file and changed some functions to suit my needs. I am working on the admin panel side of it and currently working on the roles page. Basically the ACL system provides me with all the permissions for a role based on the $roleID. I have a form with lots of radio buttons on it here is the HTML dump : Code: <table border="0" cellpadding="0" cellspacing="0" class="table"> Now on to my question. How when i submit this form can i get the value of each radio input, check its value and then update my 'permissions' table where changes have being made. I am really stuck with this I just cant seem to think of a way to build it into my 'updateRole' function. Chris How to save multiple radio boxes ??? - El Forum - 03-02-2011 [eluser]seeraw[/eluser] Hi, For this you have to give name for each radio box as array see below, <input type="radio" name="radio_name[]" /> <input type="radio" name="radio_name[]" /> <input type="radio" name="radio_name[]" /> <input type="radio" name="radio_name[]" /> <input type="radio" name="radio_name[]" /> Like this way so that when you post your form you will get an array which contains values of the check boxes you checked, Thanks, Swapnil How to save multiple radio boxes ??? - El Forum - 03-02-2011 [eluser]Derek Allard[/eluser] Actually, seeraw's suggestion probably won't work with radio buttons, since they only allow one possible answer (would work with checkbox though). All your radio buttons in your example have different names, so literally you're just going to have to grab each one of them separately: Code: $pref1 = $this->input->post('pref1'); How to save multiple radio boxes ??? - El Forum - 03-02-2011 [eluser]Bainzy[/eluser] I have managed to come up with a solution that works ( or seems to ) I will put up the code for others : Code: foreach( $_POST as $k => $v) How to save multiple radio boxes ??? - El Forum - 03-02-2011 [eluser]seeraw[/eluser] I am extremely sorry Derek Allard Yes it wont work for radio buttons It is valid only for checkboxes. I will look into this issue and get back to you soon. Thanks, Swapnil |