user3805324 user3805324 - 1 year ago 93
HTML Question

How to calculate the price according to the quantity selection in dropdown in HTML

Hi I'm doing a shopping cart like application In my dropdown user should select quantity according to that the price should be changed How to achieve that?
Heard that we can do it using onChange() function in javascript.Help me to achieve this

<p id="price"> <h3> MRP - <?php echo $row['price'] ?> </h3> </p>
<p> Total Price: Total price should load here </p>

<select class="form-control" name='item' id='item' onchange=''>
<option>Select Quantity</option>


Answer Source

You can check here the demo Demo Here

function getamount(value)
 var price=$("#price").html().replace ( /[^\d.]/g, '' );
 var amount=parseInt(value)*parseInt(price);
 $("#amount").html("Total Price: " +amount);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download