Hi All,
I have a search form that has a checkbox on it. I want the user to be able to query the database for this checkbox in three states, as follows:
1. The box is checked (return records where only the box is checked).
2. The box is not checked (return records where only the box is not checked).
3. The box is indeterminant, neither checked or unckecked (return records where both the box is checked and unchecked).
I know that there is such a thing as this called a triple state checkbox and I have used them before but I don't know how to create one in javascript. Some of the solutions I have researched seem very complicated and I have tried a small function to accomplish this on my own but it is not working. Can someone have a look and help me see whaere it is going wrong?
Thanks in advance,
Ken
I have a search form that has a checkbox on it. I want the user to be able to query the database for this checkbox in three states, as follows:
1. The box is checked (return records where only the box is checked).
2. The box is not checked (return records where only the box is not checked).
3. The box is indeterminant, neither checked or unckecked (return records where both the box is checked and unchecked).
I know that there is such a thing as this called a triple state checkbox and I have used them before but I don't know how to create one in javascript. Some of the solutions I have researched seem very complicated and I have tried a small function to accomplish this on my own but it is not working. Can someone have a look and help me see whaere it is going wrong?
JavaScript:
function triState(elem) {
var chkbox = document.getElementById(elem.id);
if (true == chkbox.checked) { //uncheck the box and set value to 0
checkbox.value = 0;
chkbox.checked = false;
}else if (true != chkbox.checked) { //make the box opaque and set value to nothing
chkbox.value = "";
checkbox.style.filter = "alpha(opacity=" + opacityValue*100 + ")"; // IE
}else{ //check the box and set value to -1
chkbox.value = -1;
chkbox.checked = true;}
}
Thanks in advance,
Ken