Ad Marketplace and Auctions
 
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read Web Directory

Go Back   Webmaster Forum > Designing and Developing Websites > Programming > Ajax / Javascript

Ajax / Javascript Discussions and help on Ajax and Javascript coding.

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2007, 04:41 AM
spinker.spanker spinker.spanker is offline
Persona Non Grata
 
Join Date: Mar 2007
Posts: 72
iTrader: (0)
spinker.spanker is on a distinguished road
Default Help writing script

I'm trying to write a script that will calculate the moon's phase based on the entered value for the position and then using basic math functions

here's what I know....

each member has a different position for the moon, they view the source code and find the number value for the position, they then enter it into the input box on my forum

if the number is >=180, it then subtracts 157.5 and divides by 22.5 then rounds the number up or down automatically

if the number is <180, it then adds 202.5 and divides by 22.5 then rounds the number up or down automatically

I've posted this on tons of other forums and only one person has tried to help

he gave me this code:
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
}
and then the html code was:
<div>
<input type="text" id="position">
<input type="submit" onclick="calculate('position');">
</div>

but when I tried that it only wrote You must enter a number! over and over again... then he wrote back that the code was wrong:
calculate('position') should be calculate(document.getElementById('position').valu e)

there are 2 instances of this: one in the javascript and one in the html coding, but no matter what that just completely disabled the whole thing....

I'm lost, help please?
Reply With Quote
Sponsored Links
Register and sign in to hide this ad block

Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT. The time now is 08:19 AM.



Freelance Web Designers
Work At Home Forum
Ad Marketplace
Online Deals and Bargains
Lunarpages Web Hosting Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0