Problem checking checkbox status using javascript
<p>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</p>

<pre><code>&lt;input type="checkbox" value="someval" name="SelectedDestinationUUID" id="SelectedDestinationUUID" onchange="maintainCheckBoxStatus(this.value,'SelectedDestinationUUID')"&gt;
</code></pre>

<p>here is my javascript</p>

<pre><code>function maintainCheckBoxStatus(checkBoxValue,checkBoxName){

    if(document.getElementById(checkBoxName).checked){
        alert("check");
        addCheckBoxStatus(checkBoxValue,true);
    }
    else{
        alert("check1");
        addCheckBoxStatus(checkBoxValue,false);
    }
}
</code></pre>

<p>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</p>

<ol>
<li><p>deselecting item 1</p></li>
<li><p>deselecting item 2
everything is working fine it showing checked and unchecked status fine.</p></li>
</ol>

<p>but if I follow the following order for deselecting</p>

<ol>
<li><p>deselecting item 2</p></li>
<li><p>deselecting item 1</p></li>
</ol>

<p>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</p>

<p>Thanks in advance</p>
