Adding price to total when checkbox is selected
<p>I would like to add a $5.00 charge whenever the txtBwayEDUGift checkbox is selected. The javascript code I currently have is reducing the amount when checkbox is unchecked, but not applying the charge when selected. I can provide additonal code if needed.</p>

<p>Here is my input type from my aspx page:</p>

<pre><code>&lt;input type="checkbox" name="txtBwayEDUGift" id="txtBwayEDUGift" onchange="checkboxAdd(this);" checked="checked" /&gt;
</code></pre>

<p>Here is my javascript:</p>

<pre><code>{
    var divPrevAmt;
    if (type == 0)
    {
        divPrevAmt = document.getElementById("divBwayGiftPrevAmt");
    }
    else if (type == 1)
    {
        divPrevAmt = document.getElementById("divBwayEDUGiftPrevPmt");
    }
    var txtAmt = document.getElementById(obj);
    var amt = txtAmt.value;
    amt = amt.toString().replace("$","");
    amt = amt.replace(",","");
    var prevAmt = divPrevAmt.innerHTML;
    try
    {
        amt = amt * 1;
    }
    catch(err)
    {
        txtAmt.value = "";
        return;
    }
    if (amt &gt;= 0) //get the previous amount if any
    {
        if (type == 0)
        {
           if (prevAmt.toString().length &gt; 0)
           {
                prevAmt = prevAmt * 1;
           }
           else
           {
                prevAmt = 0;
           }
        }
        else if (type == 1)
        {
           if (prevAmt.toString().length &gt; 0)
           {
                prevAmt = prevAmt * 1;
           }
           else
           {
                prevAmt = 0;
           }
        }
    //now update the master total
    var total = document.getElementById("txtTotal");
    var dTotal = total.value.toString().replace("$","");
    dTotal = dTotal.replace(",","");
    dTotal = dTotal * 1;
    var newTotal = dTotal - prevAmt;
    newTotal = newTotal + amt;
    divPrevAmt.innerHTML = amt.toString();
    newTotal = addCommas(newTotal);
    amt = addCommas(amt);
    txtAmt.value = "$" + amt;
    total.value = "$" + newTotal;
   }
   else
   {
        txtAmt.value = "";
        return;
   }
}
function disable()
{
    var txtTotal = document.getElementById("txtTotal");
    var txt = txtTotal.value;
    txtTotal.value = txt;
    var BwayGift = document.getElementById("txtBwayGift");
    BwayGift.focus();
}
function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length &gt; 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    var newTotal = x1 + x2;
    if (newTotal.toString().indexOf(".") != -1)
    {
        newTotal = newTotal.substring(0,newTotal.indexOf(".") + 3);
    }
    return newTotal;
}
function checkChanged()
{
    var cb = document.getElementById("cbOperaGala");
    if (cb.checked == true)
    {
        var tableRow = document.getElementById("trCheckbox");
        tableRow.style.backgroundImage = "url('images/otTableRowSelect.jpg')";
    }
    else if (cb.checked == false)
    {
        var tableRow = document.getElementById("trCheckbox");
        tableRow.style.backgroundImage = "";
    }
}
function alertIf()
{
    var i = 0;
    for (i=5;i&lt;=10;i++)
    {
        try{
        var subtotal2 = document.getElementById("txtSubTotal" + i);
        var dSubtotal2 = subtotal2.value;
        dSubtotal2 = dSubtotal2.replace("$","");
        dSubtotal2 = dSubtotal2 * 1;}
        catch (Error){dSubtotal2 = 0}
        if (dSubtotal2 &gt; 0)
        {
            alert("You have selected the I want it all package, \n however you have also selected individual tickets to the same events. \n If you meant to do this, please disregard this message.");
            break;
        }
    }
}

function disableEnterKey(e)
{
 var key;      
 if(window.event)
      key = window.event.keyCode; //IE
 else
      key = e.which; //firefox      

return (key != 13);
}

    //Add $5.00 donation to cart

    function checkboxAdd(ctl) {
    if (ctl.checked == true) {
    //            alert("adding $5");
        calculateTotal(5, "A");
    } else {
    //            alert("deducting $5");
        calculateTotal( 5, "S");
    }
} 

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