The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Help with JavaScript/HTML calculation
TomHT
post Dec 18 2016, 11:29 PM
Post #1





Group: Members
Posts: 1
Joined: 18-December 16
Member No.: 24,974



I've been working on a little website for practice. I'm trying to make it so a user puts in a number (as their 100m sprint time) and then the website calculates what pace in FIFA they would be.
The formula to work this out is: Subtract 11 from your 100m sprint time to get a figure lets call X. Then divide X by 0.2 to get another figure lets call Y. Then subtract Y from 93 and you will get your pace stat.
I've been watching videos and stuff to try and work out how to do it but I'm struggling. The image attached shows the code I've tried so far. Any help on how to do this would be much appreciated!


Attached thumbnail(s)
Attached Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 19 2016, 07:52 AM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,768
Joined: 9-August 06
Member No.: 6



Please post the actual code and HTML. We don't want to type it out. happy.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Dec 20 2016, 06:39 PM
Post #3


This is My Life
*******

Group: Members
Posts: 1,436
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Your calc2 calculation is currently dividing by 2, not .2
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 20 2016, 08:01 PM
Post #4


.
********

Group: WDG Moderators
Posts: 7,731
Joined: 10-August 06
Member No.: 7



parseFloat must begin with a lower-case p.

Also you shouldn't use document.getElementById when declaring the calc1 and calc2 variables.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 21 2016, 08:12 AM
Post #5


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,768
Joined: 9-August 06
Member No.: 6



I don't even see any elements with those IDs.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 21 2016, 08:21 AM
Post #6


.
********

Group: WDG Moderators
Posts: 7,731
Joined: 10-August 06
Member No.: 7



That's what I meant, those elements are not needed anyway. The calc variables are just used to store the calculations done on the num variable.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th November 2017 - 01:15 PM