473,385 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Grand total as an input field to forward to php

I found this awesome piece of code and it works like a charm for what I want, but if I try to make the gTotal calculate as an input field as well it will not work at all...doesn't matter if I grab it by it's id either or anything...everything I try breaks the gTotal calculation...What I need is for the gTotal to be calculated into an input field so that my php page can grab it's name and post the gTotal.
here is the code:

Expand|Select|Wrap|Line Numbers
  1. function update(el)
  2. {
  3. var tr = el.parentNode;
  4. while (tr.nodeName.toLowerCase() != 'tr'){
  5. tr = tr.parentNode;
  6. }
  7.  
  8. var qty = tr.cells[1].getElementsByTagName('input')[0].value;
  9. var cost = tr.cells[2].getElementsByTagName('input')[0].value;
  10. var total = Math.round(qty*cost*100);
  11.  
  12. tr.cells[3].getElementsByTagName('input')[0].value = cToD(total);
  13.  
  14. var rows = tr.parentNode.rows;
  15. var i = rows.length;
  16. var gTotal = 0;
  17. while (i--){
  18. gTotal += rows[i].cells[3].getElementsByTagName('input')[0].value * 100;
  19. }
  20. document.getElementById('grandTotal').innerHTML = cToD(gTotal);
  21. }
Aug 14 '14 #1
3 1693
Dormilich
8,658 Expert Mod 8TB
you have to modify the cToD() function.
Aug 14 '14 #2
Thank you for the response I tried that... I changed the function to a few old ones I had which:
Expand|Select|Wrap|Line Numbers
  1. function formatCurr(n) {
  2.     return n.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
  3. }
  4. function dm(amount) 
  5. {
  6. string = "" + amount;
  7. dec = string.length - string.indexOf('.');
  8. if (string.indexOf('.') == -1)
  9. {return string + '.00';}
  10. if (dec == 1)
  11. {return string + '00';}
  12. if (dec == 2)
  13. {return string + '0';}
  14. if (dec > 3)
  15. {return string.substring(0,string.length-dec+3);}
  16. return string;
  17. };
neither of them help me...
I changed the gTotal to:

Expand|Select|Wrap|Line Numbers
  1. tr.cells[4].getElementsByTagName('input')[0].value = dm(gTotal);
  2. document.getElementById('gTotal').value  = dm(gTotal);
neither of them work either... Sorry I guess I just don't understand this type of coding...more of a UIX than a functional coder...although I have my form 99% working. :)
Aug 14 '14 #3
I figured it out finally...so in case anyone else has this issue here is the fix and it is so simple it's embarassing. lol. :)

Expand|Select|Wrap|Line Numbers
  1. document.purchreq.gTotal.value = formatCurr(gTotal);
Aug 19 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: CSDunn | last post by:
Hello, I have 14 fields on a report that hold integer values. The field names use the following naming convention: T1Number, T2Number ....T14Number. I need to get a 'sub total' of all fields as...
5
by: simondsm | last post by:
I have a video tape library that we use at work here in a MS-Access database. When originally desgined, we never thought ot convert the time on the fly into total seconds, but instead, we stored...
0
by: jessicaeatworld | last post by:
Hi, I'm using Access 2003 on Windows XP. I have created a PivotTable View Form and at the bottom is an automatically inserted Grand Total row. I added sum and avg fields and then hid the details so...
2
by: sammiesue | last post by:
Hi, I have form with 2 autosummed textboxes ("total" and "casinototal"). I would like to have a grand total textbox ("grandtotal") get its value from summing "total" and "casinototal", but it...
0
by: Alagas | last post by:
Hi, I'm new to access 2003 & would like to know how to create a report that shows the grand total of counts, details are as the following: 1) I've a database of credit cards where I would like to...
6
by: shalskedar | last post by:
In the Report 1 of the fields contain expression.When i m trying to find the grandtotal for this field it gives me error.. For ex- The field expression is Format(,"0.00") to limit the field value...
3
by: monstez88 | last post by:
Hi, I'm trying to create a Invoice form with javascript. Basically, my invoice form should have the field item, cost, quantity and product total. It shd have a function to allow the user to add...
4
by: shalskedar | last post by:
In my Database 1 of the Report i need to find the grand total for a field which is inherited from the 1 of the subform.. Ex-The report field control source property is set to as =!Text1693 ...
2
by: GLEberts | last post by:
I am trying to calculate a Grand Total in a continuous form. This question has probably been beaten to death but I could not find any answers or solutions on how to solve. I am trying to stay away...
5
by: Chelle8263 | last post by:
Hello, I am trying to build a query that subtotals the amount of hours worked and earnings made per pay period for each employee. I built a Payroll table with employee name, start time, end time,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.