navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Problems with Javascript code

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Problems with Javascript code
Page: [1]
 
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
Tailslide

 

Posts: 5915
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: Problems with Javascript code - 2/1/2008 8:19:06   
can you show us the HTML too please.

_____________________________

"My strategy is so simple an idiot could have devised it"
Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project

(in reply to JohnH)
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

(in reply to JohnH)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Problems with Javascript code
Page: [1]
Jump to: 1





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