[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
Solved

# Calculate Total of Items in table

Posted on 2010-11-17
Medium Priority
707 Views
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
Question by:freshgrill
[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
• 3

LVL 82

Expert Comment

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

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

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

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

ID: 34203647
0

## Featured Post

Question has a verified solution.

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

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 …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
###### Suggested Courses
Course of the Month13 days, 12 hours left to enroll