i am constructing html table dynamically using java, and i want to check the checkbox automatically based on some condition, but whater the the case is the check box comes checked,
below is the code i use :
if(isactive.equalsIgnoreCase("Y")){
checked="checked";
}
else{
checked="false";
}
and the check box code :
htmlTable.append("<td align=\"left\" ><input type=\"checkbox\" name=\"headername_"+loopvariable+"\" id=\"headername_"+loopvariable+"\" value="+id+" checked="+checked+">"+columnname.toUpperCase()+"<br></td>");
if the value is not `Y` than uncheck the checkbox is my requirement but it is not working.
please advise how to go about.
Regards
Setting the
checkedproperty will yield a checked checkbox, regardless of what you set it to.You need to have the entire property in your variable:
And update your string concatenation accordingly: