|
Posted by Geoff Berrow on 02/23/07 14:00
Message-ID: <CMydnX5KLv-Fe0PYnZ2dnUVZ_rSjnZ2d@comcast.com> from Jerry
Stuckle contained the following:
>But again, JS "enhances the
>experience".
It's funny how threads pop up when you have just been working on
something.
I had an admin form with a list of records in text fields for editing.
My client wanted the choice of editing or deleting individual records so
I added a checkbox with name=' chosen[]' value='$id' and so on. Press
one button and the selected records would be updated, press another and
the chosen records get sent to a delete script.
Then I had the bright idea that the checkbox should be checked if the
text was edited to 'enhance the experience' using an onChange event.
Ok, to do that each check box would have to have a different name so I
did
name=' chosen[$id]' value='$id'
After much head scratching and cursing of JavaScript I discovered that
while php is happy with square brackets, Javascript isn't. I eventually
had to name it name=' chosen$id' value='$id'
But that meant I would no longer have my array of ids. :-(
So I did this:
foreach ($_POST as $key=>$value){
if(substr($key,0,6)=='chosen'){
$change[]=$value;
}
}
Hope this helps someone stop scratching their head as much as I did.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
[Back to original message]
|