![]() |
Multiple checkbox updating - 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: Multiple checkbox updating (/showthread.php?tid=37018) |
Multiple checkbox updating - El Forum - 12-23-2010 [eluser]Wonder Woman[/eluser] I currently have a system set up where I can delete multiple database entries using checkboxes and then submitting the form and now I want to be able to set up a feature where I can publish a number of these entries by setting the publish field in the database to 1 or 0. My problem is that I have the value of the publish checkbox as the entry id so I can't set them up as 1 or 0. Here is my Controller: Code: if($this->input->post('submit') == 'Publish') And my model: Code: function publish_competition_entries($competition_entry) { and my View: Code: if($entry['published'] == 1) { If you could help me that would be great, thanks. Multiple checkbox updating - El Forum - 01-04-2011 [eluser]Wonder Woman[/eluser] Hi, if anyone could help me with the above I would most appreciate it, thanks. Multiple checkbox updating - El Forum - 01-04-2011 [eluser]Cristian Gilè[/eluser] Hi WW, to set a checkbox as checked the third parameter of form_checkbox function needs to be TRUE or FALSE like this: Code: echo form_checkbox('publish_entry[]', $entry['id'], TRUE); not Code: echo form_checkbox('publish_entry[]', $entry['id'], 'checked="TRUE"'); When you submit the form, the post variable contains only the values of checked checkbox. For example, if you submit a form like this: Code: echo form_checkbox('publish_entry[]', 1, TRUE); the publish_entry[] array contains the first and third value but not the second. ( Code: Array ( [0] => 1 [1] => 3 ) Multiple checkbox updating - El Forum - 01-05-2011 [eluser]Wonder Woman[/eluser] Hey Cristian Gilè, Thank you so much for that, it is perfect and it works. |