Re: Passing marked rows in a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
If the elements all live within the same form, you can add [] to the end
of the name/id attribute, and then all checkboxes with the same name
will be accessible in an array.  So "checkboxname[]" will show up as
$_POST['checkboxname'] on the receiving end.
[/snip]
Can I do
  $MyArray = $_POST['checkboxname'];

And then access each array element
  for ($i = 0; $i < (count($MyAray)); $i++) echo $MyArray[$i];

Todd

Pablo Gosse wrote:

[snip]
I create a list of records from a DB and each has a check box. What is the best way to select those that were checked after the form is
submitted?
[/snip]


If the elements all live within the same form, you can add [] to the end
of the name/id attribute, and then all checkboxes with the same name
will be accessible in an array.  So "checkboxname[]" will show up as
$_POST['checkboxname'] on the receiving end.

This is the best way, and most appropriate to this list since it is all
PHP.

HOWEVER, if the checkboxes are all contained in different forms (each
form in a row with its own processing options), then you will need to
assign a common name to each element (I usually call mine
performMultiple), and then using Javascript loop through all elements on
the page, checking for the proper name, and if found then adding the
value to a comma-delimited list, the value of which will be set to a
hidden input field before the form is submitted.

HTH.

Pablo

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux