Page 1 of 1

ticked check box

Posted: Mon Jun 20, 2005 1:05 am
by Jim_Bo
Hi,

How do you make a checkbox show as checked as you would to show the selected value in a list menu:

A list menu:

Code: Select all

<option <?php echo $method=='Drive' ? 'selected' : ''?>>Drive</option>

Code: Select all

&lt;input type=&quote;checkbox&quote; name=&quote;c3&quote; value=&quote;car&quote; class=&quote;input-box&quote;&gt;
How can I display the above as checked in the same manner as the list menu.

Thanks

Posted: Mon Jun 20, 2005 1:48 am
by wyred
The word to use is 'checked'.

Code: Select all

<input type=&quote;checkbox&quote; name=&quote;somebox&quote; checked>

Posted: Mon Jun 20, 2005 2:53 am
by Jim_Bo
Hi,

I have error checking on the form, I only want it show checked if it was allready checked before it was submitted, else leave it unchecked. Same as the list/menu option above.


Thanks

Posted: Mon Jun 20, 2005 1:28 pm
by Skara

Code: Select all

<input type="checkbox" name="c3" value="car" class="input-box" <?php echo isset($c3) ? 'checked="checked"' : ''; ?> />
should be checked='checked' or selected='selected' unless you're using the old outdated crap. ;)

Posted: Mon Jun 20, 2005 5:35 pm
by Jim_Bo
Hi,

Thanks for that, works fine.