[solved] checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

[solved] checkboxes

Post by anthony88guy »

I need help with checkboxes; I’ve been fooling around with them for 2 hours. ::blush::

I have multiple checkboxes with the same name (ie. display[]). Now if the checkbox is checked it will display the info, if the checkbox is unchecked it will not. So it updates the database for example the field "display" if set to value "1" display info, if set to "0" do not display info, easy enough. Now I just have to make it work with the checkboxes accordingly.

I’m not asking anyone to write any code, just how should I go about achieving my goal.

Thanks…
Last edited by anthony88guy on Mon Feb 06, 2006 12:03 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

naming them in a self ordering fashion that can map to an existing known array can help. For instance:

Code: Select all

<input name="display[show]" value="1" />
you should have an array of all possibly checked checkboxes. Compare the ~keys you have in it to those submitted. If you do not find it, then it wasn't checked.
Post Reply