5 Replies - 5635 Views - Last Post: 03 January 2013 - 11:42 AM

#1 yaknowss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 02-January 13

Add $5.00 to shopping cart total when checkbox is selected

Posted 02 January 2013 - 01:47 PM

I am trying to apply an additional $5.00 charge to my shopping cart total when the txtBwayEDUGift checkbox is selected. I am also trying to incorporate the functionality to have that charge removed if users deselected the txtBwayEDUGift checkbox, keeping the original order amount. As of now, I am able to reduce the $5.00 amount when unchecked, but the code is not keeping the original order amount, nor is the code adding the $5.00 when selected. Below is where you will find my javascript tag function that calculates the order total. Any suggestions will be greatly appreciated! If I need to provide additional information please let me know ASAP. Thank you.

 //Add $5.00 donation to cart
    function AddAmount(checkbox) 
    {
        var action = "";
        var dGift = 5;
        if (checkbox.checked) 
        {
            action = "A";
        }
        else 
        {
            action = "S";
        }
        calculateTotal(dGift, action)
    } 


Is This A Good Question/Topic? 0
  • +

Replies To: Add $5.00 to shopping cart total when checkbox is selected

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4422
  • View blog
  • Posts: 12,289
  • Joined: 18-April 07

Re: Add $5.00 to shopping cart total when checkbox is selected

Posted 02 January 2013 - 01:53 PM

Please show us the code you are using to call this function and the body of the calculateTotal() function where you do the add/subtract of the 5 dollars.

Thanks :)
Was This Post Helpful? 0
  • +
  • -

#3 yaknowss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 02-January 13

Re: Add $5.00 to shopping cart total when checkbox is selected

Posted 02 January 2013 - 01:58 PM

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ConfirmBwaySeatDetails.aspx.cs"
    Inherits="SubRenewal.ConfirmBwaySeatDetails" %>
<%@ Register Assembly="TSC.Timeout" Namespace="TSC.Timeout" TagPrefix="tsc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title><%=SeasonDesc %> Subscription Renewal - Confirm your order information</title>
    <link href="css/main.css" rel="stylesheet" type="text/css" />
    <link href="css/Style.css" rel="stylesheet" type="text/css" />
    
    <script type="text/javascript">
    function calculate(increment, indexer)
    {
        var price = document.getElementById("divPrice" + indexer);
        var dPrice = price.innerHTML;
        dPrice = dPrice.replace("$","");
        dPrice = dPrice * 1;
        var subtotal = document.getElementById("txtSubTotal" + indexer);
        var dSubtotal = subtotal.value;
        dSubtotal = dSubtotal.replace("$","");
        dSubtotal = dSubtotal.replace(",","");
        dSubtotal = dSubtotal * 1;
        var tableRow = document.getElementById("tr" + indexer);
        if (increment == "A")
        {
            var newTotal = dSubtotal + dPrice;
            subtotal.value = "$" + newTotal.toString();
            calculateTotal(dPrice, "A");
            tableRow.style.backgroundImage = "url('images/otTableRowSelect.jpg')";
        }
        else if (increment == "S")
        {
            if (dSubtotal > 0)
            {
                var newTotal = dSubtotal - dPrice;
                if (newTotal == 0)
                {
                    subtotal.value = "";
                    calculateTotal(dPrice, "S");
                    tableRow.style.backgroundImage = "";
                    img = document.getElementById("imgSub" + indexer);
                    img.focus();
                }
                else
                {
                    subtotal.value = "$" + newTotal.toString();
                    calculateTotal(dPrice, "S");
                    img = document.getElementById("imgSub" + indexer);
                    img.focus();
                }
            }
        }
        var price2 = document.getElementById("divPrice" + indexer);
        var dPrice2 = price2.innerHTML;
        dPrice2 = dPrice2.replace("$","");
        dPrice2 = dPrice2 * 1;
        var subtotal2 = document.getElementById("txtSubTotal" + indexer);
        var dSubtotal2 = subtotal2.value;
        dSubtotal2 = dSubtotal2.replace("$","");
        dSubtotal2 = dSubtotal2 * 1;
        var txtQnty = document.getElementById("txtQnty" + indexer);
        var qnty = (dSubtotal2/dPrice2);
        if (qnty == 0)
        {
            txtQnty.value = "";
        }
        else
        {
            txtQnty.value = qnty;
        }
    }
    function calculateTotal(amountIn, type)
    {
        var total = document.getElementById("txtTotal");
        var dTotal = total.value.toString().replace("$","");
        dTotal = dTotal.replace(",","");
        dTotal = dTotal * 1;
        if (type == "A")
        {
            var newTotal = dTotal + amountIn;
            total.value = "$" + newTotal;
        }
        else if (type == "S")
        {
            var newTotal = dTotal - amountIn;
            if (newTotal == 0)
            {
                total.value = "";
            }
            else 
            {
                newTotal = addCommas(newTotal);
                total.value = "$" + newTotal;
            }
        }
    }
    function validateAmt(obj, type) //type, 0=OT League, 1=Star
    {
        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 >= 0) //get the previous amount if any
        {
            if (type == 0)
            {
               if (prevAmt.toString().length > 0)
               {
                    prevAmt = prevAmt * 1;
               }
               else
               {
                    prevAmt = 0;
               }
            }
            else if (type == 1)
            {
               if (prevAmt.toString().length > 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 > 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<=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 > 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 AddAmount(checkbox) 
    {
        var action = "";
        var dGift = 5;
        if (checkbox.checked) 
        {
            action = "A";
        }
        else 
        {
            action = "S";
        }
        calculateTotal(dGift, action)
    } 
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div id="divContainerMain">
        <div class="header">
        </div>
        <div id="mainHolder" style="width: 800px; margin: auto; margin-top: 20px;">
             <table cellspacing="0" cellpadding="2" width="800px" style="border: solid 1px #000000">
                <tr>
                    <td colspan="4">
                        <b>Please review and confirm your order information below:</b>
                    </td>
                </tr>
                  <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
                  <tr>
                    <td colspan="4" style="text-align:left;">
                        <b><%=PkgDesc %> - Number of seats: <%=NumSeats %></b>
                    </td>
                </tr>
                <tr style="background-color: #590b0b; color: White; font-weight: bold; padding: 2px">
                    <td width="75">
                        Section
                    </td>
                    <td width="50" class="row">&nbsp; Row</td>
                    <td colspan="2" style="text-align:left;">
                        Seat(s)</td>
                </tr>
                <asp:Repeater ID="repSeats" runat="server">
                    <ItemTemplate>
                        <tr class="tableRow" style="border-top:dashed 1px black">
                            <td width="75" class="row">
                                <%#Eval("zoneDesc").ToString() %>
                            </td>
                            <td width="100" class="row">
                                <%#Eval("seatRow") %>
                            </td>
                            <td colspan="3" class="row" style="text-align:left;">
                                <%#Eval("seatNums") %>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                 <tr>
                    <td colspan="4" style=" background-color:#e8e8e8; border-top:dashed 1px black">
                       <div style="float:right; margin-right:40px;"><b>Subscription Price:</b> <%=AmtDue %></div>
                    </td>
                </tr>
                <%-- <tr>
                            <td style="font-weight: bold; border: solid 1px black; color: #590b0b" colspan="4">
                                I would like to attend the Opera Tampa League's (OTL) special events:
                            </td>
                        </tr>
                        <tr style="background-color: #330023; color: White; font-weight: bold; padding: 2px">
                            <td width="100">
                                Quantity
                            </td>
                            <td width="100">
                                @ Price
                            </td>
                            <td width="450">
                                Optional Event
                            </td>
                            <td width="150">
                                Sub-Total
                            </td>
                        </tr>
                        <tr id="tr1" class="tableRow" runat="server">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',1);">
                                    <img id="imgAdd1" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',1);">
                                        <img id="imgSub1" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice1">
                                    $<%=PriceToUse %></div>
                            </td>
                            <td width="450" class="row">
                                <strong>Don Giovanni Pre-performance Dinner reception</strong><br />
                                <em>Friday, Oct. 28, 2011</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal1" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                        <tr id="tr2" class="tableRow" runat="server">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',2);">
                                    <img id="imgAdd2" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',2);">
                                        <img id="imgSub2" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice2">
                                    $<%=PriceToUse %></div>
                            </td>
                            <td width="450" class="row">
                                <strong>Don Giovanni Sunday Pass (Brunch at Maestro's Restaurant and discussion)</strong><br />
                                <em>Sunday, Oct. 30, 2011</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal2" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                        
                        <tr id="tr3" class="tableRow" runat="server">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',3);">
                                    <img id="imgAdd3" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',3);">
                                        <img id="imgSub3" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice3">
                                    $<%=PriceToUse %></div>
                            </td>
                            <td width="450" class="row">
                                <strong>Aida Pre-performance Dinner Reception</strong><br />
                                <em>Friday, April. 20, 2012</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal3" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                       
                        <tr id="tr4" class="tableRow" runat="server">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',4);">
                                    <img id="imgAdd4" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',4);">
                                        <img id="imgSub4" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice4">
                                    $<%=PriceToUse %></div>
                            </td>
                            <td width="450" class="row">
                                <strong>Aida Sunday Pass (Brunch at Maestro's Restaurant and discussion)</strong><br />
                                <em>Sunday, April. 22, 2012</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal4" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" class="row">
                                <div style="width: 100%">
                                    <div style="float: left; margin: 10px 0 0 10px; width: 25px;">
                                        <asp:CheckBox ID="cbOperaGala" runat="server" Text="" /></div>
                                    <div style="float: left; margin-left: 10px; width: 740px">
                                        I would like to attend the Opera Gala and presentation of the Anton Coppola Excellence
                                        in the Arts Award.<br />
                                        <em>Dates and ticket prices to be determined. Note: As a subscriber, you will recieve
                                            advance notification of awardee's name, ticket prices, and options for purchase.</em></div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" style="height: 5px; width: 800px">
                            </td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold; border-top: solid 1px black; color: #590b0b" colspan="4">
                                Opera Tampa's Educational programs in the Patel Conservatory's TECO Theater at $15
                                per person Master Classes will be conducted by operatic legend and Opera Tampa Artistic
                                Advisor Sherrill Mines. Guest artist TBA for Aida.
                            </td>
                        </tr>
                         <tr style="background-color: #330023; color: White; font-weight: bold; padding: 2px">
                            <td width="100">
                                Quantity
                            </td>
                            <td width="100">
                                @ Price
                            </td>
                            <td width="450">
                                Program Description
                            </td>
                            <td width="150">
                                Sub-Total
                            </td>
                        </tr>
                        <tr id="tr5" class="tableRow">
                            <td width="100"  class="row">
                                <a class="increment" onclick="calculate('A',5);">
                                    <img id="imgAdd5" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',5);">
                                        <img id="imgSub5" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice5">
                                    $15</div>
                            </td>
                            <td width="450" class="row">
                                <strong>Master Class</strong><br />
                                <em>Friday, Oct. 14, 7:30 p.m.</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal5" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                        
                        <tr id="tr6" class="tableRow">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',6);">
                                    <img id="imgAdd6" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',6);">
                                        <img id="imgSub6" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice6">
                                    $15</div>
                            </td>
                            <td width="450" class="row">
                                <strong>Prelude Series ™ - Don Giovanni</strong><br />
                                <em>Sunday, Oct. 16, 2p.m.</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal6" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                       
                        <tr id="tr7" class="tableRow">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',7);">
                                    <img id="imgAdd7" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',7);">
                                        <img id="imgSub7" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice7">
                                    $15</div>
                            </td>
                            <td width="450" class="row">
                                <strong>Master Class</strong><br />
                                <em>Friday, Jan. 13, 7:30p.m.</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal7" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                       
                        <tr id="tr8" class="tableRow">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',8);">
                                    <img id="imgAdd8" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',8);">
                                        <img id="imgSub8" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice8">
                                    $15</div>
                            </td>
                            <td width="450" class="row">
                                <strong>Prelude Series ™ - CAV/PAG</strong><br />
                                <em>Sunday, Jan. 15, 2p.m.</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal8" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                        
                        <tr id="tr9" class="tableRow">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',9);">
                                    <img id="imgAdd9" id="imgAdd8" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',9);">
                                        <img id="imgSub9" id="imgSub8" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice9">
                                    $15</div>
                            </td>
                            <td width="450" class="row">
                                <strong>Master Class</strong><br />
                                <em>Friday, March 30, 7:30p.m.</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal9" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                       
                        <tr id="tr10" class="tableRow">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',10);">
                                    <img id="imgAdd10" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',10);">
                                        <img id="imgSub10" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice10">
                                    $15</div>
                            </td>
                            <td width="450" class="row">
                                <strong>Prelude Series ™ - Aida</strong><br />
                                <em>Sunday, April 1, 2p.m.</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal10" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>
                        
                        <tr id="tr11" class="tableRow">
                            <td width="100" class="row">
                                <a class="increment" onclick="calculate('A',11);">
                                    <img id="imgAdd11" src="images/increase.jpg" /></a> <a class="increment" onclick="calculate('S',11);">
                                        <img id="imgSub11" src="images/decrease.jpg" /></a>
                            </td>
                            <td width="100" class="row">
                                <div id="divPrice11">
                                    $78</div>
                            </td>
                            <td width="450" class="row">
                                <strong>I Want it All</strong><br />
                                <em>Discount Package (all 6 educational programs)</em>
                            </td>
                            <td width="150" class="row">
                                <input id="txtSubTotal11" type="text" style="width: 75px" readonly="readonly" runat="server" />
                            </td>
                        </tr>--%>
                <tr>
                    <td style="font-weight: bold; border-top: solid 1px black; border-bottom: solid 1px black;
                        color: #590b0b" colspan="4">
                        The Center is a 501(c)3 not-for-profit corporation
                        that depends on your generous contributions as well as ticket sales to keep the
                        arts alive in the Tampa Bay area.
                        <br />Would you consider making an additional tax-deductible
                        donation to support our mission?
                    </td>
                </tr>
                <tr style="background-color: #590b0b; color: White; font-weight: bold; padding: 2px">
                    <td width="100">
                    </td>
                    <td width="100">
                    </td>
                    <td width="450">
                        Gift Description
                    </td>
                    <td width="150">
                        Gift Amount
                    </td>
                </tr>
                <tr id="tr12" class="tableRow">
                    <td colspan="2" style="border-top: solid 1px black; width:200px;">
                    &nbsp;
                    </td>
                    <td width="450" style="border-top: solid 1px black;">
                        <strong>Add a gift to support the Center</strong><br />
                        <a href="MemberBenefits.html" target="_blank">Member Benefits</a>
                    </td>
                    <td width="150" style="border-top: solid 1px black;">
                        <input id="txtBwayGift" type="text" style="width: 75px" onkeypress="return disableEnterKey(event);"
                        onchange="validateAmt(this.id, 0);" runat="server" />
                        <div id="divBwayGiftPrevAmt" style="color: #fff; font-size: 1px">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                    </td>
                </tr>
                <tr id="tr13" class="tableRow">
                    <td colspan="2" style="border-top: solid 1px black; width:200px;">
                    &nbsp;
                    </td>
                    <td width="450" style="border-top: solid 1px black;">
                        <strong>Add $5 to support arts education</strong><br />
                    </td>
                    <td width="150" style="border-top: solid 1px black;">
                      <input type="checkbox" name="txtBwayEDUGift" onclick="AddAmount(this)" checked="checked" /> <strong>Yes</strong>
                        <div id="divBwayEDUGiftPrevPmt" style="color: #fff; font-size: 1px">
                        </div>
                    </td>
                </tr>
                <tr id="tr1" class="row3">
                    <td colspan="2" style="border-top: solid 1px black; width:200px;">
                    &nbsp;
                    </td>
                    <td width="450" style="border-top: solid 1px black;">
                        <strong>Cart total will reflect gift amount upon checkout.</strong><br />
                    </td>
                    <td width="150" style="border-top: solid 1px black;">&nbsp;
                     </td>
                </tr>
                <tr>
                     <td colspan="4" class="row3" style="padding-left:60px";>&nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div style="width: 800px">
                            <div style="float: right; margin: 0 40px 0 10px; width:75px">
                                <asp:TextBox ID="txtTotal" runat="server" Width="75px" BorderColor="Black" BorderWidth="1px"
                                    onblur="disable();" onfocus="disable();" onchange="disable();"></asp:TextBox>
                            </div>
                            <div style="float: right;">
                                <b>Total:</b></div>
                        </div>
                    </td>
                </tr>
                <tr>
                      <td colspan="4" class="row">
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div style="width: 800px">
                            <div style="float: right; margin: 0 45px 0 10px; width: 100px">
                                <div class="btnSmallActive" style="float: left; margin: 5px 0 0 20px">
                                    <a>
                                        <asp:ImageButton ID="btnCheckout" runat="server" ImageUrl="images/checkOut.png" 
                                        onclick="btnCheckout_Click" /></a></div>
                            </div>
                        </div>
                    </td>
                </tr>
             </table>
            <br />
            <br />
        </div>
        <div id="footer" class="footer">
        </div>
    </div>
    <script type="text/javascript">
    var amtDue = '<%=AmtDue %>';
    var total = document.getElementById("txtTotal");
    total.value = amtDue;
    </script>
    
 <!-- BEGIN TIMER -->
    <tsc:Timeout ID="timeoutControl" runat="server" title="Webserver Session Expiring"
        TimeoutMinutes="15" AboutToTimeoutMinutes="14" Enabled="true" TimeoutURL="RenewSystemMessage.aspx?Timeout=True"
        ResetSessionOnAsyncPostback="true" CountDownSpanID="tscCounter" DirtyFormSpanID="dirtyForm"
        DisplayButton="false">
        <Template>
            <div id="sessionAlert">
                <div id="sessionAlertInner"><br />
                    <div style="width:80%; margin:auto;">
                        Your session is about to Expire. Any item(s) you have added to your cart will be
                        released if your session expires.
                        <center><br /><br />
                        <div class="btnLargeActive" style="margin: auto">
                                    <a>
                                        <asp:ImageButton ID="btnResetSession" runat="server" 
                                        ImageUrl="images/reset.png" onclick="btnResetSession_Click"
                                         /></a></div>
                            </div>
                            <br /><br />
                        </center>
                       <span id="tscCounter"></span>
                    </div>
                </div>
            </div>
        </Template>
    </tsc:Timeout>
    <!-- END TIMER -->
    </form>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3814
  • View blog
  • Posts: 13,527
  • Joined: 12-December 12

Re: Add $5.00 to shopping cart total when checkbox is selected

Posted 02 January 2013 - 02:14 PM

A cursory glance indicates that your function calculateTotal() doesn't work as you might expect. It creates local variables (total, dTotal, newTotal) which are simply discarded when the function ends.

Also, in the following code

        var qnty = (dSubtotal2/dPrice2);
        if (qnty == 0)


dividing two values is unlikely to result in 0; some inaccuracy will be involved. I would check for a value that is very close to zero.

But, as mentioned, I haven't looked at your code in detail.

BTW It is preferable that you post the resultant code (View Source) rather than the ASP version.

This post has been edited by andrewsw: 02 January 2013 - 02:16 PM

Was This Post Helpful? 0
  • +
  • -

#5 yaknowss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 02-January 13

Re: Add $5.00 to shopping cart total when checkbox is selected

Posted 02 January 2013 - 02:43 PM

Okay. I'll keep that in mind. Thanks! Any help towards my initial request will be greatly appreciated.
Was This Post Helpful? 0
  • +
  • -

#6 yaknowss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 02-January 13

Re: Add $5.00 to shopping cart total when checkbox is selected

Posted 03 January 2013 - 11:42 AM

I've also tried the following:

//Add $5.00 donation to cart
function checkboxAdd(txtBwayEDUGift) {
if (txtBwayEDUGift.checked == true) {
// alert("adding $5");
calculateTotal(5, "A");
} else {
// alert("deducting $5");
calculateTotal( 5, "S");
}
}

any additional help is appreciated.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1