# Create Percentage Calculator Using JavaScript

Create Percentage Calculator by JavaScript, Using JavaScript Calculate Percentage Calculator, Calculate JavaScript Percentage in JavaScript

Hello Friends, Today I will tell you through this tutorial how you can calculate the percentage through javascript.

So let’s go let me first tell you that people use percentage tools to calculate exams marks.

But through this tutorial, we will try to understand how to create a percentage calculator by javascript

Step 1:- First of all you have to create a html page. You can name him percentage-calculate.html. Then after that you form the form as you have been told below.

percentage-calculate.html

```<!DOCTYPE html>
<html>
<title>Create Percentage Calculator Using JavaScript</title>
<body>
<h2>Create Percentage Calculator Using JavaScript</h2>
Marks Possible Number:<br>
<input type="text" id="pointspossible"/>
<br>
Given Marks Number:<br>
<input type="text" id="pointsgiven"/>
<br>
Percentage:<br>
<input type="text" id="pointsperc" disabled/>
<br>
</body>
</html>```

Step 2:- Then after that calculate the percentage calculate that you add javascript code inside the body tag of the isi page, I have given you a good code in the same page below.

percentage-calculate.html

```<!DOCTYPE html>
<html>
<title>Create Percentage Calculator Using JavaScript</title>
<body>
<h2>Create Percentage Calculator Using JavaScript</h2>
Marks Possible Number:<br>
<input type="text" id="pointspossible"/>
<br>
Given Marks Number:<br>
<input type="text" id="pointsgiven"/>
<br>
Percentage:<br>
<input type="text" id="pointsperc" disabled/>
<br>
</body>
<script>
\$(function(){
\$('#pointspossible').on('input', function() {
calculate();
});
\$('#pointsgiven').on('input', function() {
calculate();
});
function calculate(){
var Possible = parseInt(\$('#pointspossible').val());
var pgiven = parseInt(\$('#pointsgiven').val());
var perc="";
if(isNaN(Possible) || isNaN(pgiven)){
perc=" ";
}else{
perc = ((pgiven/Possible) * 100).toFixed(3);
}
\$('#pointsperc').val(perc);
}
});
</script>
</html>```
{"ft_lang_label":"__label__en","ft_lang_prob":0.50319767,"math_prob":0.93793416,"size":2130,"snap":"2022-40-2023-06","text_gpt3_token_len":507,"char_repetition_ratio":0.16603951,"word_repetition_ratio":0.2834008,"special_character_ratio":0.2680751,"punctuation_ratio":0.14044943,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9969911,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-06T09:14:54Z\",\"WARC-Record-ID\":\"<urn:uuid:b92f5f65-1a5a-42ab-b111-5c13bbf38af1>\",\"Content-Length\":\"27445\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a503bba9-023b-4336-bcfa-644a733b3de3>\",\"WARC-Concurrent-To\":\"<urn:uuid:49c9e8d2-55a6-4bde-a8b0-3fa2eeee69c3>\",\"WARC-IP-Address\":\"104.21.50.105\",\"WARC-Target-URI\":\"https://www.expertsphp.com/create-percentage-calculator-using-javascript/\",\"WARC-Payload-Digest\":\"sha1:CPSWEEWV2HMB4OGACIH2CYTQ5GUSNILY\",\"WARC-Block-Digest\":\"sha1:R5JXWINTAWR5G4L3Q3L4CSEBBTN3Q2NN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764500334.35_warc_CC-MAIN-20230206082428-20230206112428-00326.warc.gz\"}"}