I have looked all over for an answer and hope someone here can help. I have a script that runs when you check a check box from a group of checkboxes. The checkboxes are assigned a value of "customer id"
<input type="checkbox" name="inv_add[]" onclick="setcid(\''.$result['cid'].'\')" value='.$result['id'].'/>
the point of the javascript is to assign a value to a hidden field telling the next page what the customer id is for all of checked boxes.
If you the user checks a box that is assigned to a different customer (therefore does not belong in the group) i want to alert the user and then uncheck the last box checked. I can get all the way to the alert but can not uncheck the box the user just checked.
function setcid(cid) {
if (window.set_x === undefined) {
sethidden = document.getElementById('cid');
sethidden.value = cid;
set_x = cid;
alert ("finished setting x");
}
else if (cid !== set_x){
alert ("You are trying to add two different companies to the same invoice");
/*Uncheck the box just checked by user*/
}
else {
alert("they are the same");
/*no modification required*/
}
}