|
Posted by Amer Neely on 11/12/06 21:10
flamer die.spam@hotmail.com wrote:
> Amer Neely wrote:
>> I've got a dynamically built form with checkboxes for each element ( a
>> list of file names in a directory). I need to grab only those checkboxes
>> that are checked, so I can then delete those files.
>>
>> Does each checkbox name have to be unique? I was hoping to just group
>> them under one name, and select from that array.
>>
>> PHP is not my native language - I'm coming at this from Perl, so bear
>> with me, things are a little different in that country.
>>
>> I've tried:
>> foreach ($_REQUEST as $field => $value)
>> {
>> echo "$field = $value<br>";
>> }
>> but that just grabs the last entry in the group.
>>
>> The line in question is:
>> <input type="checkbox" name="DeleteThis" value="<?php
>> echo("$allfiles[$i]")?>"> <?php echo("$allfiles[$i]")?><br>
>>
>> --
>> Amer Neely
>> w: www.softouch.on.ca/
>> b: www.softouch.on.ca/blog/
>> Perl | MySQL programming for all data entry forms.
>> "We make web sites work!"
>
> in html, if your checkbox is called "blah123" then when its checked it
> will have the variable name of blah123 with a value of blah123, if it
> is unchecked then blah123==null. the easy way is:
>
> if (!empty($_POST['blah123'])) { do stuff }
>
> Flamer.
>
I can now grab the selected elements, but only if they are selected by
mouse clicks. If I use the JavaScript toggle to select/unselect all,
nothing gets passed to the PHP. This works in Perl, so it has to be
doable in PHP I would think.
--
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
Perl | MySQL programming for all data entry forms.
"We make web sites work!"
Navigation:
[Reply to this message]
|