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")[0].appendChild(text);
- }
- }
- function provideAnswer(phase) {
- // Do Something
- }
Expand|Select|Wrap|Line Numbers
- <div>
- <input type="text" id="position">
- <input type="submit" onclick="calculate('position');">
- </div>
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?