Checkboxs and array indices

From: Nik Coughin (nrkn!no-spam!_at_woosh.co.nz)
Date: 12/22/04


Date: Wed, 22 Dec 2004 17:19:19 +1300

I am having a problem with checkboxes...

I have a number of blocks like this on my form:

<input type="text" name="name[]" value="a name">
<input type="text" name="ddi[]" value="1234">
<input type="checkbox" name="delete[]">

If I then submit the form, the array $delete is the only one which isn't
indexed by its order on the form.

For example, $name[ 0 ] and $ddi[ 0 ] always return the value of the first
name[] and ddi[] input on the form.

If I check any one of the checkboxes, say the third one, then $delete[ 0 ]
will be "on", and all of the other including $delete[ 2 ] will be off.

If I checked the third and seventh checkbox, just as an example, $delete[
0 ] and $delete[ 1 ] will be "on".

So, there is no way I can tell which checkboxes are actually checked, just
how many have been checked. This is extremely annoying and doesn't happen
with any of the other form controls. Any ideas?

-- 
"Come to think of it, there are already a million monkeys on a million 
typewriters, and the Usenet is NOTHING like Shakespeare!" - Blair Houghton
-=-=-=-=-=-=-=-=-=-=-=-
 http://www.nrkn.com/
-=-=-=-=-=-=-=-=-=-=-=- 


Relevant Pages

  • Re: Managing 70 checkboxes in financial graphing application
    ... to manage how the checkboxes interact with the data and the graph. ... I have a tab with the data series called "Data". ... This allows the graph to show blanks where data is missing as some series ... My idea is to read the status of all checkboxes into an array. ...
    (microsoft.public.excel.programming)
  • Re: Updating Multiple Rolls Using PHP
    ... I am retrieving records from a table and I ... checkboxes, but my update loop is not working. ... array $_POST. ... Warning: Invalid argument supplied for foreach() in X: ...
    (comp.lang.php)
  • Re: even rows for checkbox forms with no splitting of boxes from values
    ... So I usually roll my own checkboxes. ... In the solution below I wanted to randomize the test script a little ... #this is to create an array with 25-50 strings 2-10 in length ...
    (comp.infosystems.www.authoring.cgi)
  • Re: Grabbing checkbox values
    ... I need to grab only those checkboxes that are checked, so I can then delete those files. ... This array contains data from different ... The 'param' function is part of a perl module that deals with form parsing. ...
    (comp.lang.php)
  • RE: Excel 2003 VBA question
    ... the state of checkboxes until the user clicks "Ok". ... Make a temp array of 6 ... addresses as needed and increment the recipientCount ... If the sendMail function will work with a recipient string like ...
    (microsoft.public.excel.programming)