I need your help please! I want to multiply the quantity with the single price and put it in id called total using Ajax( I don't know Ajax well)
$(function () {
"use strict";
$('.qty').on('keyup', function () {
var singl_price = $(".single_price").val(),
qty = $(".qty").val(),
total_price = qty * singl_price;
$("#total").text(total_price);
$.ajax({
url: 'cart.php',
type: 'POST',
data: '',
success: function (data) {
if (data === "ok") {
}
},
error: function (e) {
}
});
});
});
<form action="cart.php" method="post" >
<input type="text" name="qty" class="qty" value="<?php echo $_POST['qty']; ?>" />
</form>
<div class="single_price"> 20 </div>
<div id="total"> </div>
</div>