I made a function for a select with duplicate selection. It's working well, but as I remove any one option from that select, then my array remains same.
If I remove any option then my code will detect that particular option value so I can remove it from my AllProductArray array.
var AllProductArray = [];
function SelectProductWisely() {
var SelectedProduct = $('#SelectProduct').val();
if (SelectedProduct.length !== 0) {
AllProductArray.push(parseInt(SelectedProduct));
}
console.log({
SelectedProduct,
AllProductArray
});
$('#SelectProduct').val(0);
$.ajax({
url: 'API.php',
type: 'GET',
data: {
ReqType: "CheckLimitPrice",
Product: AllProductArray
},
success: function(response) {
console.log(response);
if (response < 1100) {
console.log("done");
} else {
console.log("done");
enter image description here
}
},
})
}

Sorry for the late reply I was away,
THis should show you how to do what you want, if you just use the events from
https://harvesthq.github.io/chosen/options.html
You can use the change even to capture if an item is being added or removed from the select list and update your array accordingly
I hope this helps