Re: Posted form values - checkbox problem

From: Date: Mon, 18 Dec 2000 22:31:41 +0000
Subject: Re: Posted form values - checkbox problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-30949@lists.php.net to get a copy of this message
HTML limitation. When a form is submitted, only checkboxes that are checked get sent back. If it bugs you, and you can't get around it by keeping track of which checkboxes COULD have been there, use radio buttons. Michael Kimsal wrote: > > cow1.php > <form method="post" action="cow2.php"> > <input type="checkbox" name="cow"> > <input type="submit"> > </form> > > cow2.php > <? echo phpinfo();?> > > If you run cow1.php, then have it submit to cow2, > there will be no HTTP_POST_VARS["cow"] unless > the "cow" is checked. I've no way of knowing > if 'cow' was the name of a checkbox on the form that > wasn't checked, or just not a checkbox at all. > > Runing PHP4.03pl1 if that makes a difference. > > David Tod Sigafoos wrote: > > > Hello Michael, > > > > Monday, December 18, 2000, 13:51:27 PM, you wrote: > > > > MK> <input type="checkbox" name="cow"> > > MK> <input type="checkbox" name="pig"> > > MK> <input type="checkbox" name="dog"> > > > > MK> If cow is 'checked', I get $cow="on", > > MK> but if cow is left unchecked, I get $cow="". > > > > MK> If I knew the names of the variables I was > > MK> getting, I could check to see if they were 'on' or '', > > MK> but I don't know. I'm getting an array of disparate > > MK> values, and I can't tell which checkboxes were on > > MK> or off, only those that were on. > > > > MK> Any ideas, short of including a separate hidden value that > > MK> tells me which variable names I'll be getting? > > > > I am sure I am missing something .. but the control 'name' is the var > > name. You know you have a checkbox called cow, pig and dog so you > > will have vars $cow, $pig and $dog... yes? > > > > wait a minute .. am i on candid camera? <g> > > > > > > -- > ========================== > Michael Kimsal > http://www.tapinternet.com > PHP Training courses > http://www.tapinternet.com/php > > -- > 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 (#30949) next »