Re: Re: error checking a null array
| From: | Jochem Maas | Date: | Mon, 01 Aug 2005 13:44:03 +0000 |
| Subject: | Re: Re: error checking a null array | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-219747@lists.php.net to get a copy of this message | ||
Jack Jackson wrote:
g.gill wrote:wtf are you smoking Jack? every checkbox that was checked will exist in the $_POST array set with the value you gave it (I alway set a chekcboxes value to 1 because the values mere existance in the submitted data indicates it's chevckbox was checked), if a checkbox does not exist in the $_POST array it wasn't checked!!! imagine you have 10 checkboxes named 'cb1' thru 'cb10' each with a value of '1', upon submitting the form they are in, your script sees the following in the $_POST array... $_POST = array('cb1' => '1', 'cb9' => '1', 'cb10' => '1'); which tells you 3 checkboxes were checked... namely 'cb1', 'cb9' and 'cb10' now how hard is it to determine which we're not checked? maybe I'm not seeing the problem but I get the impression that you are over complicating things regarding checkbox.That helped, sonu, thank you. The problem now is that, how can I pass through $_POST the names of each specific checkbox, whether filled in or not, and then parse each to see if they have any answer? I need to do that or else I can only tell the ones which *have* been filled in but not those which have not.From what I understand the simplest solution here would be to check to seeif you have $_POST['cb'] in the first place. That would indicate if checkbox was selected or not. After, you have posted the form just do the following test. $check_box_exits = ((isset($_POST['cb']))? true:false);
Thanks