Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
mike mm
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't repeat till it gets the equation right though
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic