Non selected submited form-array values

From: Date: Thu, 30 Aug 2001 14:34:32 +0000
Subject: Non selected submited form-array values
Groups: php.general 
Request: Send a blank email to php-general+get-65289@lists.php.net to get a copy of this message
Hi All, I already spent too much time trying to solve this one by myself, so I am in need of a little bit of help. I have a form with checkboxes, all with the same name (name="noticias[]"). When it is submited, only the selected checkboxes become a value on the array $noticias on the next page. So: <checkbox name="noticias[]" value="m" checked> <checkbox name="noticias[]" value="w"> $noticias will have only one value, 'm'. Right? I come to this conclusion, but I might be wrong. The values are dinamic, which means not always certain boxes will be checked or have the same value, form by form. So form X can have 3 checkboxes with different values than form Y with 8 checkboxes. Okay. Now I need to compare the submited values with another 'parsed string', or not if I took the wrong path from the beggining to solve this problem. For example: $string = 'w=1&r=0&m=0'; parse_str($string); // Will become $w = 1, $r = 0, etc... Back with the array $noticias, I need to compare the selected values with the ones on the parsed string, still mantaining the parts equal to zero. If array $noticias will only have values with the checked boxes, how can I 'update' the $string (returning a new one, for example) with the new checked boxes and still maintain the ones that equals to zero, if the $string can have an uncertain number of values after parsed? That's a hard one, I believe ;-) Say, just to clarify, another example: $noticias = Array("m","d") $string = "m=0&d=1&w=1&d=0"; The resulted string would need to be: "m=1&d=1&w=0&d=0"; A solution I am trying to unfold for dinamic (or uncertain) strings, it to make a function that one of the parameters is the 'old string', which I would pass to this function, to serve as a 'base' to be updated with the values from the form array ($noticias). But I am stuck at the part where this old string is compared, and its values are updated if the form's checkboxs are selected, or not. Am I missing some simple function from the manual that can do this for me? If not, how can I accomplish this result? Thanks a lot if you read it until here ;-) -- Julio Nobrega A hora está chegando: http://toca.sourceforge.net

« previous php.general (#65289) next »