"Jeff Lewis" <[EMAIL PROTECTED]> wrote in message
> I have a form where users can enter a link
> (kind of a free for al links type of thing)
> When they add their site to the database
> a 0 is added to the "approved" field.
> When I load an admin script I can check
> all of the ones that have a 0 in that field.
> I want to have checkboxes form down the
> side of them so I can check the ones I want
> approved.
> Is it possible to have them all update with the
> click of one submit button?

There are two obvious approaches to this:

First, with JavaScript, you could write a
'select all' button, which checks all the checkboxes,
then submits the form normally.

Or, you could have a submission button
that tells PHP to approve all listed items
whether checked or not, ie

<input type='submit' name='submit' value='Checked'>
<input type='submit' name='submit' value='All'>

The problem with this is that unchecked checkboxes
simply don't appear when the form is submitted; you
need some way to get a full list of the IDs in question.

A quick fix I have found is as follows, for each option:

<input type='hidden' name='cb307' value='No'>
<input type='checkbox' name='cb307' value='Yes'>

NOTE: the name is NOT an array, and the hidden
field must come before the checkbox.
This way, if the checkbox is not checked, the 'No'
value comes through; otherwise it is over-written
by 'Yes'.

Another option would be to keep a comma-delimited
list of IDs and write 'em all into a single hidden
field, ie

<input type='checkbox' name='cb305' value='Yes'>
<input type='checkbox' name='cb306' value='Yes'>
<input type='checkbox' name='cb307' value='Yes>
<input type='hidden' name='idlist' value='305,306,307'>

Hope this helps...

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to