[FX.php List] Suggestions on editing a list of check boxes

Bob Patin bob at patin.com
Mon Sep 1 11:24:41 MDT 2008


Hi John,

I thought we talked about this the other day...

I have my own method, which works great; I'm sure there are other  
methods, but this one is fairly easy:

On your form:

If you are creating a dynamic set of checkboxes, you'll need to make  
sure each checkbox's name is unique. I do this with a counter:

$counter = 0;

Then, in a FOREACH loop, generate your checkbox HTML code, and make  
the name end with the counter variable:

name="myCheckbox_<?php echo $counter; ?>"

I use an underscore just to make it easy for me to read...

Then, after this FOREACH loop, put an invisible field that contains  
the value of $counter; you'll use this on the processing page.
---------------
ON THE PROCESSING PAGE:

//retrieve the value of your COUNTER variable
$counter = $_POST['counter'];

Retrieve the checkbox values by using a WHILE loop:

$x = 0;
while ($x < $counter){
	$myCheckboxList = $_POST['myCheckbox_'.$x].'<br>';
	$x++;
}

Then, in your EDIT query, write the value of $myCheckboxList to your  
checkbox field.

I'm doing this all from memory, but that's essentially how I do it.  
You don't really need to use an array, since you're grabbing the  
checkbox values and assembling them into a list that you'll write to  
the field.

Hope this makes sense; I'm too lazy to dig up one of my pages and copy  
out the code...


--
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 Sep 1, 2008, at 10:52 AM, John Funk wrote:

> I have HTML form that list the results of an FM query in a check box  
> format.
> I would like to then send that list (all (records with user changes)  
> back to
> the same FM layout (table) with FMEdit().
> Can anybody give an example for capturing, sending and getting  
> arrays of
> data between php files, then parsing to edit the records? I  
> understand the
> FMEdit() part.
>
> My form part to show to check list:
> $RecID=$record['RecordID'][0];
> $Category=$record['Category'][0];
> $YrSelected=$record[' YrSelected'][0];
>
> echo "<input name=RecID type=hidden value=".$RecID.">";
> echo "<input name=YrSelected type=checkbox value=".$YrSelected;
>
> if ($YrSelected >"")
>
> echo " checked>".$Category."<br>";
> else
> echo " unchecked>".$Category."<br>";
>
>
> This seems so simple but the more I work on it the more I get  
> screwed up.
> Thanks
> John Funk
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list