I'm working on jsp application and I have a form that has a checkbox, I retrieve data from my database which has a bit field named "principal", I can get the value of this field which is a boolean but I can't checked or unchecked the checkbox depending on the value of "principal".
Here's my JSP code:
<tr>
<td>Principal:</td>
<td colspan="2">
<input type="checkbox" id="a_principal" name="a_principal" value="<%=directorio.isPrincipal()%>"/>
</td>
</tr>
Javascript code:
$(function (){
if('#a_principal' == true){
$("input:checkbox").attr('checked', true);
}else{
$("input:checkbox").attr('checked', false);
}
});