Javascript checkbox increment and decrement
<p>What i want is that when a user click a checkbox in otherwords uncheck decrement when check it increment.</p>

<pre><code>echo "&lt;td&gt;&lt;input type=checkbox name='check1' id='check1' value='".$info['eventCategory']."' onclick=if(this.checked){recal(" . $info['totalEvents'] . ",true)} else if(!this.checked){recal(" . $info['totalEvents'] . ",false)}   checked&gt;&lt;/td&gt;&lt;td&gt;" . $info['id'] . "      " . $info['name'] . "&lt;/td&gt;";
</code></pre>

<p>i wrote above code and
Only true statement is works </p>

<pre><code>&lt;script language="JavaScript"&gt;
            function recal(val,sum)
            { 
                if(sum == true)
                {
                    var total = parseInt(document.getElementById("total").innerHTML, 10);
                    total+=val;
                    document.getElementById("total").innerHTML=total;
                }
                else
                {
                    var total = parseInt(document.getElementById("total").innerHTML, 10);
                    total-=val;
                    document.getElementById("total").innerHTML=total;   
                }

            }
        &lt;/script&gt;
</code></pre>

<p>What i want  is to execute also else statement. I mean when user uncheck it must also decrease the number.</p>

<p>Thank you.</p>
