Home:ALL Converter>Checkbox - in Javascript

Checkbox - in Javascript

Ask Time:2012-09-23T23:12:35         Author:smiley

Json Formatter

I am working on Edit screen where I am pulling out value from db to check if the checkbox is checked or not.

If it is unchecked, it should deselect the checkbox and other controls of this checkbox. In my case the js works perfectly fine. That is if my previous screen has checkbox unchecked, edit screen disables all the values for this checkbox. But it still shows the checkbox is checked in UI(though it is actually checked). Something is wrong with my html code.

Can someone please let me know where /how should i modify to display if my checkbox is unchecked?

<%chkStatus=list.getCheckbox();
         if (chkStatus == null) { chkStatus = ""; }
 %>

   <input id="chkbox" type="checkbox" name="chkbox" checked="<%=chkStatus%>"  
                                onchange="javascript:enableDisableTextBox();">

Author:smiley,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12553472/checkbox-in-javascript
Richard Close :

checked is a boolean attribute, so you should have:\n\n<input id=\"chkbox\" type=\"checkbox\" checked />\n\n\nfor the checked state and \n\n<input id=\"chkbox\" type=\"checkbox\" />\n\n\nfor the unchecked state. (selected in <select><option/> </select> is an example of another boolean attribute).",
2012-09-23T15:24:51
yy