RE: [PHP] setting Check box

From: Date: Tue, 27 Mar 2001 05:26:32 +0000
Subject: RE: [PHP] setting Check box
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45696@lists.php.net to get a copy of this message
Use that code, $avail just isn't evaluating to 'n' so try this somewhere above it : $avail = 'n'; And it will be checked otherwise it won't. And btw, you tried setting value="n" that won't work unless this script submits to itself AND the user checks it before submitting so it'll remain checked. What are you wanting to do and where does $avail originally come from? Regards, Philip On Tue, 27 Mar 2001, 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 >

« previous php.general (#45696) next »