If checkbox is checked value="0" if is not checked value="1"?
Hello all,
I'm trying to get my checkbox functionality to work depends on if check box is checked or not. If I click on the checkbox and is Checked I should send value="0" with my Ajax call. In other case if I unchecked my checkbox I should send value="1" with my Ajax. Here is the code that I have so far:
<td><input type="checkbox" name="block" id="block" onChange="updateTable('#CustomerID#')"></td>
function updateTable(CustomerID){
if(document.getElementById('block').checked == true){
var blocked = 0;
var whObj = {"url":"/apps/StudentAdmin/ParentTeacherConfScheduler/PTCAjaxFunction.cfc?method=UpdateSchedule&returnformat=json"};
gwAjaxPost(whObj,{"CustomerID":CustomerID,"blocked":block},Result);
}else if(document.getElementById('block').checked == false){
var unblocked = 1;
var whObj = {"url":"/apps/StudentAdmin/ParentTeacherConfScheduler/PTCAjaxFunction.cfc?method=UpdateSchedule&returnformat=json"};
gwAjaxPost(whObj,{"CustomerID":CustomerID,"unblocked":block},Result);
}
}
This code above always submit value 1. Does not matter if I checked or unchecked the checkbox. I'm not sure why, if anyone see where is my code breaking or if you know any other way how I can send different values please let me know.
