[FX.php List] Suggestions on editing a list of check boxes
Gjermund Gusland Thorsen
ggt667 at gmail.com
Tue Sep 2 09:56:22 MDT 2008
Suggestion
---
echo '<input type="hidden" name="RecID[]" value="' . $RecID . '">';
---
ggt667
2008/9/2 John Funk <csinfo at comcast.net>:
> Chris your suggestion works great for sending the data to POST but how do I
> extract the data? Once I have the data in a variable (not an array) I know
> what to do.
> My field to send data:
> echo "<input type=hidden name=RecID[] value=".$RecID.">";
>
> My code to get the array:
> $RecIDs = array($_REQUEST["RecID"]);
>
> How do I extract the data with foreach()?
> John
>
>
>
>
> -----Original Message-----
> From: fx.php_list-bounces at mail.iviking.org
> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Gjermund Gusland
> Thorsen
> Sent: Monday, September 01, 2008 3:00 PM
> To: FX.php Discussion List
> Subject: Re: [FX.php List] Suggestions on editing a list of check boxes
>
> That approach name="myArray[]" in combination with recid can make you
> achieve some serious stuff.
>
> ggt
>
> 2008/9/1 Chris Hansen <chris at iviking.org>:
>> John,
>>
>> Bob is right about checkbox naming (if you're not careful, you'll end up
>> with only that last value in the list), but there's a very elegant way to
>> handle this: name your checkbox element with empty square brackets.
>>
>> <input type='checkbox' name='my_checkbox[]' value='some_value' />
>>
>> What this does, is cause PHP to automagically assemble all checkbox values
>> for a given set into an array. Neat, eh? Just be sure to check that
> values
>> were submitted before stepping through that PHP array with foreach() or
>> you'll get an error.
>>
>> HTH
>>
>> --Chris Hansen
>> FileMaker 7/8/9 Certified Developer
>> Creator of FX.php
>> "The best way from FileMaker to the Web."
>> www.iViking.org
>>
>> On Sep 1, 2008, at 11:24 AM, Bob Patin wrote:
>>
>>> 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
>>>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>
>>
>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>
> _______________________________________________
> 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