Hi This is a HTML code for a check box. I need to take the value of the checkbox(true/false).
<input id="is-student" type="checkbox" value="Student Related"/>
<input id="open-new" type="button" value="Open New" onclick="openNew();"/>
This is the java script code for take the input value from the checkbox.
var testJson = JSON.stringify({
reference: [{
studentRelated: document.getElementById("is-student").checked
}]
});
function openNew()
{
window.openNew(testJson);
}
My problem is document.getElementById("is-student").checked
always return false. If we click the checkbox, this part returns false, and if we not click the checkbox, then also return false.
I need to fix that and when we click the checkbox, then document.getElementById("is-student").checked
part should return true and if we did not click, then should be return false
. How can I do that?