I have a form where user can enter details and choose an item by selecting checkbox.
On clicking of add button checked item values and user input values stored in array and i am passing these values in url.
User can add multiple items with different name and email. Suppose i have three items so user can choose item1 and fill name1 and email1 and click on add button and similarly if he select item1 and item2 and add name2 and email2, he can add these value.
On each click i want to check item id if its already present in array i don't want to add it, just increase quantity of that item which is already there in array and update array with new quantity
var allVals = []; //array where i am storing selected checkbox value
jQuery("#btnadd").click(function(event) { //on click of this button i am getting all values to construct url and pass this value to multi div from where i will validate my url
var qty;
jQuery(".selectitem:checked").each(function() {
qty = jQuery(this).next().find('input[name="quantity"]').val()); //getting quantity of selected checkbox its a input field
if (jQuery.inArray(jQuery(this).val(), allVals) == -1) {
allVals.push(jQuery(this).val() + ',' + qty); //item id not present in array so adding item id,qty in array
} else {
qty = qty + 1;
//here i would like to increase quantity of those items only which already present in array something like this.qty and update my allVal array with this new quantity
}
});
var rslt = allVals.join(';'); jQuery('#multi').val(rslt); //updating multi div value with allVals from here i will make redirect. Just want to pass correct values in that field
});