Jquery and Javascript Program to Calculate SI?

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript">
       
      function calculate()
      {

          p = document.getElementById("txtp").value;
          r = document.getElementById("txtr").value;
          t = document.getElementById("txtt").value;
          si = (p*r*t)/100;
          //document.write("result is "+si);
        document.getElementById("res").innerHTML="result is "+si;
      }

    </script>
</head>
<body>

<input type="text" id="txtp" placeholder="Enter P" />
<br>
<br>
<input type="text" id="txtr" placeholder="Enter R" />
<br>
<br>
<input type="text" id="txtt" placeholder="Enter T" />
<br>
<br>
<input type="button" value="click" onclick="calculate()" />

<br>
<div id="res"></div>
</body>
</html>


Jquery Code:-
download from
https://jquery.com/download/
<!DOCTYPE html>
<html>
<head>
    <title></title>
  <script src="jq.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(document).ready(function(){

      $("button").click(function(){

         p = eval($("#txtp").val());
      r = eval($("#txtr").val());
      t = eval($("#txtt").val());
      si = (p*r*t)/100;
    
        $("#res").html("result is "+si);

      });

    });


  </script>
   
</head>
<body>

<input type="text" id="txtp" placeholder="Enter P" />
<br>
<br>
<input type="text" id="txtr" placeholder="Enter R" />
<br>
<br>
<input type="text" id="txtt" placeholder="Enter T" />
<br>
<br>
<button>click</button>

<br>
<div id="res"></div>
</body>
</html>

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post