Can some one tell me why this script isn't working?
mike mm
Greenhorn
Joined: May 08, 2005
Posts: 7
posted
0
Can some one tell me why this script isn't working?
<html> <head> <script> var varix = 2 var vari1 = 0 var vari2 = 0 var varie = 0 funtion calc { document.write(x) var vari1 = varix * varix var vari2 = varix * 2 var varie = vari1 + vari2 if (varie == 10) { var varix = varix + 0.0000001 calc } else { document.write(" x equals " varix) } } </script> </head> <body onload="calc()"> </body> </html>
This is meant to start on the page loading, and repeat till it gets the value of x, any ideas. Please post in full code rather that telling me to add something somewhere or some technical jargon because it will not understand.
Many Thanks, Mikemm
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
0
the variable x is never declared, think you wanted it to be varix. The word function is spelled wrong.
Some other errors I see are You should not declare the varaible again: var vari1 = varix * varix var vari2 = varix * 2 var varie = vari1 + vari2 should be vari1 = varix * varix vari2 = varix * 2 varie = vari1 + vari2 varix = varix + 0.0000001
next: when calling the fucntion again calc should be calc()
also
document.write(" x equals " varix) is missing a + document.write(" x equals " + varix)
all together we get:
mike mm
Greenhorn
Joined: May 08, 2005
Posts: 7
posted
0
It doesn't repeat till it gets the equation right though