Solved

Add $5.00 amount to shopping cart total when checkbox is selected

Posted on 2012-12-27
16
298 Views
Last Modified: 2013-01-13
I want the cart total to apply an additional $5.00 charge when the txtBwayEDUGift checkbox is selected. I would also like to have the ability to have that charge removed if users deselect the txtBwayEDUGift checkbox. I've attached my aspx page, lines 11-233 is where you will find a javascript tag function that calculates the order total.

Thank you.
ConfirmBwaySeatDetails.aspx
0
Comment
Question by:is_staff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 3
  • 3
16 Comments
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 38725134
Try this javascript

function AddAmount(checkbox)
{
    if (checkbox.checked)
    {
        var txtCartTotal= document.getElementById("txtCartValue");
        int temp=txtCartTotal.value + 5;
    }
    else
    {
       var txtCartTotal= document.getElementById("txtCartValue");
        int temp=txtCartTotal.value - 5;
    }
}

Open in new window



HTML CODE -
<input type="checkbox" name="txtBwayEDUGift" onclick="AddAmount(this)" />

Open in new window

0
 

Author Comment

by:is_staff
ID: 38725151
Okay, I'll give it a shot and let you know the results. You may not hear back from me until tomorrow morning. Thank you!
0
 

Author Comment

by:is_staff
ID: 38727472
Hi there,

So after applying your code I went to debug and encountered the following instances:

Sample1 - Cart is not adding $5.oo to total.
Sample2 - Is the message i received when I unchecked the check box.
sample1.jpg
sample2.jpg
0
How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

 
LVL 19

Expert Comment

by:Manoj Patil
ID: 38727769
0
 

Author Comment

by:is_staff
ID: 38728026
Hmm.. this didnt help me. If you have any other thoughts I would greatly appreciate it. Thank you
0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 38728177
Get the Code from same site
See example here.
http://jsbin.com/abukor/2
It displaying the alert message. You can edit it by my previous code.
For addition you first need to parse the text box value like

int temp1=parseInt(txtCartTotal.value,0) + 5;
0
 

Author Comment

by:is_staff
ID: 38728201
Thank you for your response. I'm having difficulty interpreting the examples you provided.  Maybe I am overlooking something? To my understanding, the examples provide a pop up message and that is not what i am looking for. I was hoping to enable javascript to add a $5.00 amount to the cart total.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 38731051
I would use your calculator function to handle this:

function AddAmount(checkbox)
{
    var action = "";
    var dGift = 5;
    if (checkbox.checked)
    {
        action = "A";
    }
    else
    {
        action = "S";
    }
    calculateTotal(gift, action)
}

Open in new window


/gustav
0
 

Author Comment

by:is_staff
ID: 38732583
Okay, I'll give it a shot and let you know my result. Thank you.
0
 

Author Comment

by:is_staff
ID: 38736751
cactus_data -

Thank you for your input. I tested your code. The cart total is now including the additional $5.00 charge. When the checkbox is unchecked, it is reducing the amount in the cart total, however, it is not reducing the subscription price. See my attached screen shots for further clarification.

Thank you.
1.jpg
2.jpg
0
 

Author Comment

by:is_staff
ID: 38742052
I added the following code:

<input type="checkbox" name="txtBwayEDUGift" onchange="checkboxAdd(this);" checked="checked" />
<script type="text/javascript">
function checkboxAdd( ctl ){
 if(ctl.checked == true ){
   calculateTotal(5, "A");
  } else {
   calculateTotal( 5, "S");
  }
} 

It appears the functionality is there and is working to an extent. But instead of adding the $5.00 charge to the order, it is instead keeping the orginal amount and only reducing the amount when unchecked. It is not adding the $5.00 to the order amount when checked. Please see my screenshots attached. With the $5.00 added the order amount should be $1,126.00 in my example. I hope this makes sense. Please help in anyway possible. thank you.


</script>  

Open in new window

1.jpg
2.jpg
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 38743588
I don't know, but you could use a similar technique to adjust the other (total)field.

/gustav
0
 

Author Comment

by:is_staff
ID: 38743800
how so?
0
 

Accepted Solution

by:
is_staff earned 0 total points
ID: 38755123
got it. I needed to add jquery to make it work:

function load()
{
alert("Page is loaded");
}
</script>
</head>

Open in new window


<body onload="load()">

Open in new window



I also needed to add this to my c# page:

if (txtBwayEDUGift.Checked)
            {
                addDonations(5.00m, 93);
            }

Open in new window

0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 38755200
Great!

/gustav
0
 

Author Closing Comment

by:is_staff
ID: 38771593
discovered answer by adding jquery and c# code to existing solution.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question