Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

not getting the multiplication in 4th text box

I want to multiply the three numbers entered in three seprate textbox id is(PaperHeight & PaperWidth & Rate) and then get the product in fourth textbox id is (FinalRate)

I want to get the output when the submit button is clicked

following is my code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function btnclick() {
  var PictureHeight = document.getElementById('PictureHeight').value;
  var PictureWidth = document.getElementById('PictureWidth').value;
  var Rate = document.getElementById('Rate').value;
  var FinalRate = document.getElementById('FinalRate').value;

  FinalRate = parseInt(PictureHeight) * parseInt(PictureWidth) * parseInt(Rate);

}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <link rel="stylesheet" href="style.css">
  <title>Calculator</title>
</head>

<body>
  <center>

    <h1>Rate Calculator</h1>

    Enter the Picture dimention and Rate<br/>

    <div class="container">
      <div class="row">
        <div class="col">

          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">Width</label>
            <input type="number" class="form-control" id="PictureWidth">
          </div>

        </div>

        <div class="col">
          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">Height</label>
            <input type="number" class="form-control" id="PictureHeight">
          </div>
        </div>

        <div class="col">
          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">Rate</label>
            <input type="number" class="form-control" id="Rate">
          </div>
        </div>
        <br>

        <div class="col">
          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">&#8377;</label>
            <input type="number" class="form-control" id="FinalRate">
          </div>
        </div>


      </div>
    </div>

    <button type="button" class="btn btn-primary" onclick="btnclick()">Submit</button>


  </center>




  <script src="script.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous">
  </script>
</body>

</html>

>Solution :

get the element and then set the value.

function btnclick() {
  var PictureHeight = document.getElementById('PictureHeight').value;
  var PictureWidth = document.getElementById('PictureWidth').value;
  var Rate = document.getElementById('Rate').value;
  var FinalRate = document.getElementById('FinalRate');

  FinalRate.value = parseInt(PictureHeight) * parseInt(PictureWidth) * parseInt(Rate);
  

}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <link rel="stylesheet" href="style.css">
  <title>Calculator</title>
</head>

<body>
  <center>

    <h1>Rate Calculator</h1>

    Enter the Picture dimention and Rate<br/>

    <div class="container">
      <div class="row">
        <div class="col">

          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">Width</label>
            <input type="number" class="form-control" id="PictureWidth">
          </div>

        </div>

        <div class="col">
          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">Height</label>
            <input type="number" class="form-control" id="PictureHeight">
          </div>
        </div>

        <div class="col">
          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">Rate</label>
            <input type="number" class="form-control" id="Rate">
          </div>
        </div>
        <br>

        <div class="col">
          <div class="input-group input-group-sm mb-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">&#8377;</label>
            <input type="number" class="form-control" id="FinalRate">
          </div>
        </div>


      </div>
    </div>

    <button type="button" class="btn btn-primary" onclick="btnclick()">Submit</button>


  </center>




  <script src="script.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous">
  </script>
</body>

</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading