RE: [PHP] setting Check box

From: Date: Wed, 28 Mar 2001 01:08:08 +0000
Subject: RE: [PHP] setting Check box
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45804@lists.php.net to get a copy of this message
use <SELECT NAME="foo"> <OPTION VALUE="bar" <? if ($areacode == 'bar') { echo 'SELECTED '; }?>>foo bar</OPTION> Peter Ps thanks again David & Jason M & Phillip for your help :> -----Original Message----- From: S. Efurd [mailto:steve@goquest.com] Sent: Wednesday, March 28, 2001 10:48 AM To: php-general@lists.php.net Subject: Re: [PHP] setting Check box This worked for me as well, and helped me with a problem I was having! How would you show what option was selected in a drop down box. I have a form the user fills out, this goes to a confirmation page to ensure the data enetered is correct. I have a drop down box for states, and I cant seem to make it show the state selected it always defaults to first choice? Thanks ----- Original Message ----- From: "David Robley" <huntsman@www.nisu.flinders.edu.au> To: "Peter Houchin" <peterh@vfsa.com.au>; "Php-General@Lists. Php. Net" <php-general@lists.php.net> Sent: Monday, March 26, 2001 11:37 PM Subject: Re: [PHP] setting Check box > On Tue, 27 Mar 2001 14:24, Peter Houchin wrote: > > >> Hiya can some one pls let me know if i am on the right track pls, > > >> this is in a form that updates if there is an id else it inserts, > > >> now what i want it if there is an id i want the check box to be > > >> either checked or unchecked depending on the 'y' / 'n' value > > >> in the > > >> db > > > > > > > > >> <input type="checkbox" name="avail" value="" > > >> <? if ($avail == 'n') > > >> { echo 'SELECTED '; }?>"> > > > > > > > > >> Peter Houchin > > > > > > > > > Try CHECKED for checkboxes - SELECTED works for dropdowns. > > > > > > ok I've changed it the SELECT to CHECKED but it had no effect ... > > <input type="checkbox" name="avail" value="" <? if > > ($avail == 'n') { > > echo 'CHECKED'; }?>> > > I've also tried it with a "n" value so it reads like > > <input type="checkbox" name="avail" value="n" <? if > > ($avail == 'n') { > > echo 'CHECKED'; }?>> but that didn't have any luck either ... is > > there > > anything else i can do? > > Peter > > Well, this little snippet works for me... > > <?php > $avail = 'n'; > ?> > > <FORM ACTION=check.php METHOD=GET> > <input type="checkbox" name="avail" value="" <?php if > ($avail == 'n') > echo 'CHECKED'; }?>> > <INPUT TYPE=SUBMIT> > </FORM> > > <?php > if(isset($avail)) { > echo "Value of AVAIL: $avail"; > } > ?> > > If you aren't getting the value you expect in $avail you may have > problems. > > -- > David Robley | WEBMASTER & Mail List Admin > RESEARCH CENTRE FOR INJURY STUDIES | > http://www.nisu.flinders.edu.au/ > AusEinet | Ü > r¿õœ¦6F¼ÀÚhttp://auseinet.flinders.edu.au/ > Flinders University, ADELAIDE, SOUTH AUSTRALIA > > -- > 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 > > -- 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 (#45804) next »