Simple problem ,
I am trying to populate html form check-boxes dynamically, but when i try to do this by using checked property of the checkbox in html it not works correctly . The checkbox remain checked whether i use checked='0' / checked='1' , checked='true' / checked='false' and checked='checked' / checked='unchecked'.
although i solved it by applying extra checks in php as following…
while($contact = $db->fetchByAssoc($contacts))
{
$include_checked =( $contact['include'])? " checked={$contact['include']} ": "";
$opted_checked = ($contact['opted_out'])? " checked={$contact['include']} ": "";
$html.="<tr><td>{$contact['name']} </td>
<td><input type='checkbox' {$include_checked}/> </td>
<td><input type='checkbox' {$opted_checked}/> </td>
Is there any better solution to do it???
Use
yesto preselect it. Remove it to uncheck it by defaultor `checked=”checked”
Or, but deprecated and not encouraged to use:
Unchecked? Don’t use any option at all. Just remove it. Through back-end there is no way to not select it. And of course this is not needed at all.