guyzdancin1
Programmer
I have a jsp page of check boxes, some of which have identical id's. When I click a checkbox (selected or unselected), I want all the rest of the check boxes of the same id to switch to the same state as the box I just clicked. My problem is that the check boxes are dynamically loaded to the jsp, ultimately from a properties file. So I cannot pass a literal check box id to a java script function in the "onclick" attribute of the input tag. The java script method needs to know within the method block the check box id value and the state of the check box.
Here is the code I have with pseudo code where my knowledge is lacking.
You help is thanked in advance
======================================== CODE ==========================================
function checkBoxSynch(formName){
var allCheckBoxes = document.getElementById(formName);
var currentCheckBox = ** GET THE CHECKBOX THAT WAS JUST CLICKED **
var state = currentCheckBox.checked;
for(var i = 0; i < allCheckBoxes.elements.length; i++ ){
if(currentCheckBox.name == allCheckBoxes.elements.name )
allCheckBoxes.elements.checked = state;
}
}
Here is the code I have with pseudo code where my knowledge is lacking.
You help is thanked in advance
======================================== CODE ==========================================
function checkBoxSynch(formName){
var allCheckBoxes = document.getElementById(formName);
var currentCheckBox = ** GET THE CHECKBOX THAT WAS JUST CLICKED **
var state = currentCheckBox.checked;
for(var i = 0; i < allCheckBoxes.elements.length; i++ ){
if(currentCheckBox.name == allCheckBoxes.elements.name )
allCheckBoxes.elements.checked = state;
}
}