[FX.php List] How to get a string of valuse from a form

Bob Patin bob at patin.com
Tue Aug 26 15:23:59 MDT 2008


What Steve suggested is similar to what I do here:

I create a counter, then as I'm putting the checkboxes on the HTML  
form, I'm incrementing the counter and using it in the checkbox's  
name, like this:


<?php
$counter = 0;

foreach($queryResults['data'] as $key=>$queryData){
?>
// create the checkbox
<input type="checkbox" name="theName<?php echo $counter; ?>"  
id="checkbox" />
<?php
$counter++; // increment the checkbox
}
<input type="hidden" name="numCheckboxes" id="hiddenField" value="<? 
php echo $counter; ?>"/>
?>

So what you end up with is checkboxes named

theName0
theName1
theName2
...

An array will work great, and is certainly more elegant, but this  
accomplishes the same thing.

Then, on the processing page, I use the hidden field "numCheckboxes"  
to tell me how many boxes I had displayed, so that I can loop through  
and retrieve their values in a FOREACH loop.

Hope this helps... dashed off rather quickly,

Bob Patin
Longterm Solutions
bob at longtermsolutions.com
615-333-6858
http://www.longtermsolutions.com
iChat: bobpatin
AIM: longterm1954
FileMaker 9 Certified Developer
Member of FileMaker Business Alliance and FileMaker TechNet
--------------------------
FileMaker hosting and consulting for all versions of FileMaker
PHP • Full email services • Free DNS hosting • Colocation • Consulting

On Aug 26, 2008, at 12:53 PM, John Funk wrote:

> I have a form that displays  a list of check boxed items, some  
> checked some not data is from a child table. They are all the same  
> text field “name” because they are from the same field in the  
> related table. In PHP, How do I “collect” only the checked items so  
> the next process can insert this list of items to a single field in  
> the parent table?
> John Funk
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20080826/b6ac2127/attachment.html


More information about the FX.php_List mailing list