I am not very comfortable using javascript so trying my hands to use this in my one project,i have a small work which i have to impliment using javascript.
on my JSP page i need to display a list of items which checkbox against each item and need to track if user select a item or deselecting an item.
here is what i am trying
<input type="checkbox" value="someval" name="SelectedDestinationUUID" id="SelectedDestinationUUID" onchange="maintainCheckBoxStatus(this.value,'SelectedDestinationUUID')">
here is my javascript
function maintainCheckBoxStatus(checkBoxValue,checkBoxName){
if(document.getElementById(checkBoxName).checked){
alert("check");
addCheckBoxStatus(checkBoxValue,true);
}
else{
alert("check1");
addCheckBoxStatus(checkBoxValue,false);
}
}
now what happening is when i am selecting items it showing checked correctly but when unselecting the behaviour is something different
here are the details
let’s suppose i have two items and i selected first than second and while deselecting i deselecting in the following order
-
deselecting item 1
-
deselecting item 2
everything is working fine it showing checked and unchecked status fine.
but if I follow the following order for deselecting
-
deselecting item 2
-
deselecting item 1
Things got messed while deselcting item two the alert showing me that its status is selected.
can any one point me where i am doing wrong
Thanks in advance
Firstly please do
which is the same as