Source Code For Percentage Calculator

Source Code For Percentage Calculator In js, html and css format (word file)


To Test Code visit-

Just Copy Paste This Code

<!DOCTYPE html>



  <title>Percentage Calculator</title>

  <link rel=”stylesheet” type=”text/css” href=”style.css”>



  <h1>Percentage Calculator</h1>

  <div class=”container”>

    <label for=”number”>Number:</label>

    <input type=”number” id=”number”>

    <label for=”percentage”>Percentage:</label>

    <input type=”number” id=”percentage”>

    <button onclick=”calculatePercentage()”>Calculate</button>

    <p id=”result”></p>


  <script src=”script.js”></script>



.container {

  max-width: 300px;

  margin: 0 auto;

  text-align: center;


input, button {

  margin-top: 10px;


button {

  padding: 5px 10px;


#result {

  margin-top: 20px;

  font-weight: bold;


function calculatePercentage() {

  var number = parseFloat(document.getElementById(“number”).value);

  var percentage = parseFloat(document.getElementById(“percentage”).value);

  if (isNaN(number) || isNaN(percentage)) {

    document.getElementById(“result”).innerHTML = “Please enter valid numbers.”;

  } else {

    var result = (number * percentage) / 100;

    document.getElementById(“result”).innerHTML = “Result: ” + result.toFixed(2);



Leave a Comment

Your email address will not be published. Required fields are marked *