Re: how do I find out which checkbox is checked when form get submit

From: Date: Wed, 18 Apr 2001 10:13:38 +0000
Subject: Re: how do I find out which checkbox is checked when form get submit
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49171@lists.php.net to get a copy of this message
If a checkbox is NOT checked, the attached PHP variable is NOT set. Only if it is checked will you be able to see/query the variable "id" Using isset() should allow to you see the boolean state of a checkbox, or using the "value" component after you do an isset() call will give you the specifics. 'Luck -Szii ----- Original Message ----- From: Matt Williams <matt@yewlands.com> To: Jacky <jacky@activelifestyle.com>; <php-general@lists.php.net> Sent: Wednesday, April 18, 2001 2:26 AM Subject: RE: [PHP] how do I find out which checkbox is checked when form get submit > Hi Jacky > > In it's simpliest form try this > ################################### > <form action="<?= $PHP_SELF; ?>" method="get"> > <input type="checkbox" name="id"><br/> > <input type="submit" name="submit" value="submit"> > > </form> > <?php > echo (isset($id)) ? "checked" : "not checked"; > ?> > ################################## > > > > > > > Hi all, > > Extremely desparate here as I still cannot get my problem sought > > out, so decided > > to post my question again. > > Allow me to repeat my question again: > > I have a form with the checkbox like this > > <form> > > <?php > > $query="select id from foo"; > > $result=($query,$con); > > while ($row = mysql_fetch_array($result)) > > { > > print("<input type="checkbox" name="$id" > > value="on">"); > > } > > ....submit button and stuffs here... > > ?> > > </form> > > <input type="checkbox" name="$id" value="on"> > > > > > After I tried check on few checkboxes and submit to next page, at > > next page, how do I check which check box is > > checked so that I can get value of the checked one to process to > > next step? > > I did try isset() and empty() to check if variable exist ( as shown below) > > and did not work as the result always turn up to be "off" > > > > if((empty($id))=='true'){ > > echo "off"; > > }else{ > > echo "on"; > > } > > > > And I also try > > if(isset($id)) > > { > > ..do echo off here... > > }else{ > > ...do echo on.... > > } > > > > And the result is always "off" as well. > > > > Somene advice me to use $http_var_gets btu I could not find it > > from manaual, > > is that the solution I need? > > cheers > > > > Jack > > jacky@activelifestyle.com > > "There is nothing more rewarding than reaching the goal you set > > for yourself" > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#49171) next »