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,

Member Avatar for diafol

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.

Thank you very much for you answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.