wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Can some one tell me why this script isn't working? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Can some one tell me why this script isn Watch "Can some one tell me why this script isn New topic
Author

Can some one tell me why this script isn't working?

mike mm
Greenhorn

Joined: May 08, 2005
Posts: 7
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: 15376
    
    6
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
It doesn't repeat till it gets the equation right though
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can some one tell me why this script isn't working?
 
Similar Threads
2>11 results true with java script variables
floating image in firefox ? still in trouble ^_^
JavaScript and JApplet
how to call javascript function in the previous html file
MultiDimenaional Array sort