Solved

Calculate Total of Items in table

Posted on 2010-11-17
5
694 Views
Last Modified: 2012-06-27
On a web page, an order form in a table, before user clicks on "submit/order", I want to auto summarize line items and order total (showing order table on both top and bottom of page).

example:

Order Total: $36
Item A $4  user puts in quantity 3 = auto total $12
Item B $6 user puts in quantity 4 = auto total $24
Order Total: $36
0
Comment
Question by:freshgrill
  • 3
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 34160532
var AUTO_TOTAL_A = parseFloat(document.getElementById("ItemAID").value) * parseInt(document.getElementById("QuantityItemAID").value);
var AUTO_TOTAL_B = parseFloat(document.getElementById("ItemBID").value) * parseInt(document.getElementById("QuantityItemBID").value);
var ORDER__TOTAL = (AUTO_TOTAL_A + AUTO_TOTAL_B).toFixed(2);
document.getElementById("autototalIDA").value = AUTO_TOTAL_A;
document.getElementById("autototalIDB").value = AUTO_TOTAL_B;
document.getElementById("ordertotalID").value = ORDER__TOTAL;

0
 

Author Comment

by:freshgrill
ID: 34169671
I don't get what I am suppose to do with that, do I have to do ItemAID, ItemBID for each row in the table? And also for the ORDER_TABLE? The number of rows are dynamic each time.
0
 
LVL 20

Expert Comment

by:ddayx10
ID: 34170004
Do you have an example of the html of the table layout you suggest? Otherwise we guess, it's a little off and we have to write code again to obtain the result you want. I understand the number of rows is dynamic, but how are the cells laid out. Show a sample html table layout and it can be done in a few min.
0
 

Accepted Solution

by:
freshgrill earned 0 total points
ID: 34173438
I found the code and example at: http://www.mcfedries.com/javascript/ordertotals.asp
0
 

Author Closing Comment

by:freshgrill
ID: 34203647
Found my own answer
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now