Solved

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

Posted on 2012-12-27
16
297 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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 50

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 50

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 50

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adjust the codes 3 63
c#  FTP ftpwebrequest URI invalid 6 47
Using asp.net to develop android, ios, windows APPS 7 55
ASP.NET VB code for check and insert in a table 4 45
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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