Page 1 of 1

checkbox in form field problem

Posted: Wed Dec 17, 2008 2:36 pm
by steve_linn
In an update form, how do I create a checkbox field?

here is an example of my code:

Code: Select all

 
 
<tr><td><h3>Admin Pref</h3></td><td><input type="text" name="adminpref" value="' .$row[adminpref].'"></td></tr>
    
<tr><td><h3>Video</h3></td><td><input type="checkbox" name="video" value="<?php if ('.$row[video].'=="1") 
    {echo "checked"};?>"</td></tr>
I cannot get the checkbox to be checked when the database value is set to 1....
thanks

Re: checkbox in form field problem

Posted: Wed Dec 17, 2008 2:41 pm
by John Cartwright
The value attribute has nothing to do whether the checkbox is checked or not. It is it's own attribute.

A checked checkbox would look like

Code: Select all

<input type="checkbox" checked="checked" />