Re: Checkbox in PHP form
| From: | Adam Randall | Date: | Tue, 10 Nov 2009 19:50:39 +0000 |
| Subject: | Re: Checkbox in PHP form | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299769@lists.php.net to get a copy of this message | ||
<INPUT class="text" id="myCheck1" type="checkbox"<?php echo(
$row[33] ==
'no' ? ' checked="checked"' : '' ); ?>
value="PFDs"
name="f_sequipment1"></b><font size="2">PFDs<b>
Or with short tags:
<INPUT class="text" id="myCheck1" type="checkbox"<?= $row[33] ==
'no' ? '
checked="checked"' : '' ?> value="PFDs"
name="f_sequipment1"></b><font
size="2">PFDs<b>
Adam.
On Sun, Nov 8, 2009 at 5:39 PM, Ernie Kemp <ernie.kemp@sympatico.ca> wrote:
> Need some help here with checkboxes in an html form.
>
>
>
> My issue is I have a form that needs to be viewed with checkboxes filled in
> depending on the values in the table.
>
>
>
> I tried:
>
> <INPUT class=text id="myCheck1" type=checkbox <?php if ( $row[33] =
> 'no')
> { echo "checked=yes"; } else { echo ''; } ?> value="PFDs"
> name=f_sequipment1></b><font size="2">PFDs<b>
>
> but the checkbox field is always checked.
>
>
>
> I thought of JavaScript also but it would have to be a “if $row[33] then
> run a JavaScript function” . This is not working for me neither.
>
>
>
> Sorry if this seems trivial but I need your help.
>
>
>
> Thanks in advance.....
>
>
>
>
>
>
>
>
>
--
Adam Randall
http://www.xaren.net
AIM: blitz574