Hi,
I have a trouble. I have select option with value. I need to make sum of each of ths selct option. But when you select nothing happen.
PHP
$(document).ready(function() {
$("#products select").on("change", function() {
var id = this.value;
$.ajax({
url: "ajax.json",
method: "get",
data: "id=" + id,
success: function(response) {
//initialize totalPrice to 0 if doesn't contain a value
var totalPrice = $("#totalprice").val() !== "" ? parseInt($("#totalprice").val()): 0;
var datashow = response;//JSON.parse(response);
var price1 = parseInt(datashow[0].price);
/*var time1 = datashow[0].time;*/
//add the total price
$("input#totalprice").val(totalPrice + price1);
//Do something similar for time, I don't how you plan on parsing this?
/*$("input#totaltime").val(time1);*/
}
});
});
});
-
1
-
2
-
3
-
4
-
5
Jignesh KumarRank #91 · 22.9K reputationPosted Aug 4, 2022, 4:11 AM EDT