Welcome Guest, Not a member yet? Register   Sign In
Handling Multiple Checkboxes
#1

[eluser]Unknown[/eluser]
Hello CI community ---

I'm pretty new to CI and I'm trying to figure out the best way to persist multiple checkbox values to the DB. I searched the forums for a bit but did find anything I was looking for.

Here is what I have so far..In the DB I have a column set up for each checkbox with the goal of persisting either a 1 or 0 depending if the checkboxes is checked.

Code:
&lt;input type="checkbox" name="day[]" value="1" id="monday"  /&gt;&lt;label for="monday">&nbsp;Monday</label><br />
&lt;input type="checkbox" name="day[]" value="1" id="tuesday"  /&gt;&lt;label for="tuesday">&nbsp;Tuesday</label><br />
&lt;input type="checkbox" name="day[]" value="1" id="wednesday"  /&gt;&lt;label for="wednesday">&nbsp;Wednesday</label><br />
&lt;input type="checkbox" name="day[]" value="1" id="thursday"  /&gt;&lt;label for="thursday">&nbsp;Thursday</label><br />
&lt;input type="checkbox" name="day[]" value="1" id="friday"  /&gt;&lt;label for="friday">&nbsp;Friday</label><br />

Most of the checkboxes are grouped so I have named them the same. My issue, as I understand it, is sometimes not all the checkboxes are checked every time the form is submitted so they won't show up in the POST. Which then leads me to my next problem of mapping each value in the POST to my DB table. What is the most effective way to handle this issue?

Thanks,

Ryan


Messages In This Thread
Handling Multiple Checkboxes - by El Forum - 01-03-2010, 12:13 PM
Handling Multiple Checkboxes - by El Forum - 01-03-2010, 12:29 PM
Handling Multiple Checkboxes - by El Forum - 01-03-2010, 12:31 PM
Handling Multiple Checkboxes - by El Forum - 01-03-2010, 12:37 PM
Handling Multiple Checkboxes - by El Forum - 01-03-2010, 01:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB