|
| |
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
Problems with Javascript code - 2/1/2008 8:16:51
Hi, I found the folling code on the Internet that I use to take VAT (UK tax) from a total amount. By the way, this script is placed in between the HEAD tags. <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function doMath() { var one = eval(document.FrontPage_Form1.total.value) var two = eval(document.FrontPage_Form1.vat.value) var prod = one / two document.FrontPage_Form1.PURCHASE_VALUE.value=custRound(prod,2); } function custRound(x,places) { return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) } // End --> </SCRIPT> The problem I have is that the javascript only seems to work if FrontPage_Form1 is the first form in the page. That is not the case in my HTML. Can anyone help? Many thanks, John
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Problems with Javascript code - 2/1/2008 8:22:37
I have just fixed it! I replaced document.FrontPage_Form1 with document.forms[2] [2] being the 3rd form in my page. It uses 0 as the first. Thanks, John
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|