Calculating with javascript -


ok have html , want calculate quantity * priceperitem numbers put in input . thx in advance.

book store

<h3>please select books</h3> <div>     <label for="quantity">quantity</label>     <input type="text" id="quantity" /> </div> <div>     <label for="quantity">price per item</label>     <input type="text" id="priceperitem" /> </div> <div>     <button>view price</button> </div> <div class="payment-info">     amount pay: <span id="total"></span> </div>   $(document).ready(function() { var quantity = $("#quantity"); var price = $("#priceperitem");  $("total").text(price * quantity); });` 

$(document).ready(function() {    $('button').on('click',function(){    var quantity = parsefloat($("#quantity").val());  var price = parsefloat($("#priceperitem").val());  $('#total').html(price * quantity);  });    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <h3>please select books</h3>  <div>      <label for="quantity">quantity</label>      <input type="text" id="quantity" />  </div>  <div>      <label for="quantity">price per item</label>      <input type="text" id="priceperitem" />  </div>  <div>      <button>view price</button>  </div>  <div class="payment-info">      amount pay: <span id="total"></span>  </div>


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -