Click to See Complete Forum and Search --> : Javascript help

04-13-2007, 05:10 AM
Hello all
i need some help with this program that i'm trying to make

i'm new at this so it's probably a dumb mistake but i can't find it :(

function Bereken_onclick()
horizontalspeed = prompt("Give the horizontal speed in meters per second","")
height = prompt("Give the height of the plane in meters.","")
verticalspeed = (height*2*9.81)^0.5
distance = (horizontalspeed*verticalspeed)/9.81
tg = height / distance
arctangens = Atn(tg)
angle = 60*arctangens
document.write("The pilot has to drop the bomb when he sees the target under an angle of " + angle + " degrees.")

and the error it gives:

Line : 17
char : 1
code : 0
error : Object expected

pls help :)

04-14-2007, 04:25 AM

A couple of possible problems - I don't think there is a ^ operator in Javascript - Instead you can use,

Math.pow(height * 2 * 9.81, 0.5);

or in this case,

Math.sqrt(height * 2 * 9.81);

The other thing was is the function Atn defined anywhere?

You could try using


04-14-2007, 08:37 AM
^ works fine :)
I didn't know about the Math.sqrt, thx for that :thumbsup:

But I already solved my problem, it was indeed Atn that didn't work (altho i found it in the help-database from the program itself -_-)
I had to use Math.atan(tg)

thx for the fast reply tho :)