PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Mon Jun 20, 2005 1:05 am
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
<input type="e;checkbox"e; name="e;c3"e; value="e;car"e; class="e;input-box"e;>
How can I display the above as checked in the same manner as the list menu.
Thanks
wyred
Forum Commoner
Posts: 86 Joined: Mon Dec 20, 2004 1:59 am
Location: Singapore
Post
by wyred » Mon Jun 20, 2005 1:48 am
The word to use is 'checked'.
Code: Select all
<input type="e;checkbox"e; name="e;somebox"e; checked>
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Mon Jun 20, 2005 2:53 am
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
Skara
Forum Regular
Posts: 703 Joined: Sat Mar 12, 2005 7:13 pm
Location: US
Post
by Skara » Mon Jun 20, 2005 1:28 pm
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.
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Mon Jun 20, 2005 5:35 pm
Hi,
Thanks for that, works fine.