Help! Going mad!

F

Fred Bloggs

Hi, I'm a complete newbie to javascript.
I downloaded the script
http://javascript.internet.com/math-related/calculate.js

to use in a seminar registration form. It works fine in IE7, but in FF
nothing happens. When I look at the error console it gives the error:

Line 20: Calc is not defined (line 20 is
if (calc.item1.checked){I've looked all over the net to find out why FF
doesn't like this. Can anyone help? What should it be changed to?Many
thanks.Fred.
 
F

Fred Bloggs

Thanks, and I read 4.41, but as a complete ignoramus on javascript, I don't
have a clue what it means! What bit should I change? Where do I add the
document.getElementById or does it replace a part of the existing code?

Cheers
J.
 
F

Fred Bloggs

The problem is, because I know nothing about javascript, I don't know how to
solve it!
You're quite right about the error: it is actually written thus:

if (calc.item2.checked){
var witem2 = document.calc.item2.value = item2price;

} else {

var witem2 = document.calc.item2.value = 0;

}

And that's what FF is picking up on.

The actual html stuff is at
http://javascript.internet.com/math-related/checkbox-calculator.html and
appears to be a very popular download, with no reported problems, but it is
seven years old.

When I copied and pasted it into IE7, and linked it to the js file, it
worked fine first time. It just doesn't want to know in FF.

If it's not a valid reference, then I guess the script never would have
worked? Also, as you say, why then does it work okay in IE7?

J.
 
G

Gregor Kofler

Fred Bloggs meinte:
If it's not a valid reference, then I guess the script never would have
worked? Also, as you say, why then does it work okay in IE7?

It *only* works in IEs because it relies on non-standard DOM
"specialities" only provided by these browsers.

The solution is already stated in the FAQ: Replace "calc" with
document.getElementById("calc").

Gregor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top