Re: Re: error checking a null array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jack Jackson wrote:

Jochem Maas wrote:
<snip>


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!!!


Oh, how I wish I were smoking something :) !

no you don't, you want to go home and rethink your life ;-)


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?


Well, for me, it is - because I don't know the names of the other check boxes which were not checked because they were dynamically created, and

you wouldn't be the one who wrote the script that creates them dynamically would you?

and if you hit the same URL 100 times you get the same checkboxes? (i.e. its
checkbox output is reproducable) ... of so you have the basis for dynamically checking which
checkboxes where presented to the user by using the same logic/algorithm to
check for there exist on submit as you use to generate them in the first place.

if your smart/able (and it's posible) you will wrap this logic up in some kind
of function in order to not duplicate code/logic...

in fact you could just store all the names of these checkboxes in a multidimensional
array in the session when you create them and use that as the basis to check
for [non]existance.

I don't have the knowledge sufficient to pass the NAMES of all

???

checkboxes through to $_POST so that I can search through and see which have been answered and which ones not.


why is it important to know what was not checked?



maybe I'm not seeing the problem but I get the impression that you are
over complicating things regarding checkbox.


As always this is hugely possible.

:-)



JJ


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux