I have been working on a custom select where every added service will increase the cost on first input. Then within the same category it wouldn't add any more.
https://jsfiddle.net/0mvubg2L/1/
On first click of the Class 45 category service, it should add 100, then after that it should calculate 0. But it's adding all the elements together to make 300.
Then if you were to add a service from Class 44, it would also add 100, and so on.
I tried making an update function
function update(param) {
var total = 0;
$(".search-results .results-group.ready .item, .search-results .results-group.added .item").each(function() {
total += + param;
});
$(".total").text(total);
}
and then making an on click to send it through, but I can't figure out the correct method to implement this.
var itemReady = $(".search-results .results-group.ready .item");
itemReady.on("click", function() {
$(this).parent().removeClass('ready');
$(this).parent().addClass('added');
update('100');
});
itemAdded.on("click", function() {
update('0');
});