|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Right, here goes:
I need to return the value of a checkbox and perform a function or two using that value. My checkbox(es) are call "chk0[]" and the value's are the ID of the same row, for example: ID | Artist | Album | Genre | Record Label | Year | Rating | Delete ------------------------------------------------------------------------------------ 001 Rem blah ... ... ... 4 [] (checkbox) 002 Incubus ..... ... ... .... 5 [] ...etc The checkbox name for the first checkbox is "001", second is "002" etc according to the value in the ID row. So when an entry is checked and "Delete" is clicked, i need to compare the value of "chk0[]" (checkbox) with the elements in an array. I'm using "strstr" so if i refer to the checkbox - $id = ($_POST['chk0[$countvariable]']) does it return the value or simply "true" (if it is checked??). I've tried changing several things but when I try to "strstr" the elements in the array it never returns a match, please help! Many thanks, Phil |
|
#2
|
||||
|
||||
|
Checkboxes are tricky to deal with... they are only visible in the $_POST variable iwhen they're physically checked... meaning, if nothign is checked than $_POST('chk0') isn't set.
Is there a particular reason you've put square braces in your checkbox name? this may complicate things... Perhaps you could try chkbox[0] instead of chkbox0[]... Once doing so, you could use foreach ($_POST['chkbox'] as $chk) Any help at all? |
|
#3
|
|||
|
|||
|
It could help, but I'm using square brackets so that I can give each checkbox a name, which is the ID of the corresponding row. Then all I need to do is somehow return the VALUE of the checkbox and check for a match in the array. Then *hopefully* simply unset the element in the array, therefore deleting it, I hope.
Thanks for the suggestion, if my original idea doesnt work then I'll opt for yours |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Returning values...! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|