0

Hello,

I'm trying to get a javascript to work, unfortunately i'm not that good with javascript.

What i'm trying to make is the following:
I have 3 input fields:
Total amount of dossiers:
Total amount of cleared dossiers:
Total amount of filed dossiers:

The first one is the total amount of dossiers, for example 200
The second one is the amount i already cleared, for example 50
The third one is the amount i logged, for example 20.

I would like the webpage to display the following 2 calculations:
First one should give me the percentage of cleared dossiers: in this example 25%
The second one should give me the percentage of logged dossiers: in this example 10%

Could someone please help me wit this?

Kind regards,

2
Contributors
2
Replies
21
Views
2 Months
Discussion Span
Last Post by Wytse
0

The code is very close to how you'd write the sum itself:

var filedpc = filed * 100 / total;

However you need to place the input values I to variables and change them to integers before calculating. Have a look at parseInt and getElementById. Optionally you may wish to round percentages to a certain precision. For this look at the Math functions.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.