464,564 Members | 947 Online Need help? Post your question and get tips & solutions from a community of 464,564 IT Pros & Developers. It's quick & easy.

# help with script

 P: 1 I need to make a script that will calculate the moon phase based on the moon's position... it's for an online game here's what I've got - members locate the position by viewing the page source and it's always a number then they would enter that number into an input box and submit it, which then would figure the answer one of 2 ways: if the number is >=180, it subtracts 157.5 and then divides by 22.5, rounds the number and that's the answer if the number is <180, it adds 202.5 and then divides by 22.5, rounds the number and that's the answer I've posted on several different coding forums to try to get help: I wrote a script once before with lots of help from other people but I didn't know half of what I was doing or even what it all meant, just that it did what I wanted it to... so on one forum someone posted this: Expand|Select|Wrap|Line Numbers function calculate(position) {   var phase;   position = parseFloat(position);   if (position > 180) {      phase = Math.round((position - 157.5) / 22.5);      provideAnswer(phase);      }   else if (position < 180) {      phase = Math.round((position - 202.5) / 22.5);      provideAnswer(phase);      }   else {     var text = document.createTextNode("You must enter a number!");     document.getElementsByTagName("div").appendChild(text);     }   }   function provideAnswer(phase) {   // Do Something   } and the html code was Expand|Select|Wrap|Line Numbers

all that did was write You must enter a number! over and over again then he said that the code was wrong and that calculate('position') should be calculate(document.getElementById('position').valu e) but when I changed the values in both the script and the html it just disabled it completely please help? Feb 23 '07 #1 