Some how it becomes very complicated for me to achieve this.
// HERE WE WILL ARE CREATING THE ARRAY OF OBJECTS
let getAllAssetsData = [];
$('#productList tr').not(':first').each(function(index,value){
let getPT = $(this).find('.dropdown').val();
let getPm = $(this).find('.pm').val();
let getSn = $(this).find('.sn').val();
getAllAssetsData.push({
'pt' : getPT,
'pm' : getPm,
'sn' : getSn,
});
});
// THIS IS WHAT I AM TRYING
$(getAllAssetsData).each(function(index1,value1){
$(getAllAssetsData).each(function(index2,value2){
// HERE I NEED TO COMPARE ALL ARRAY VALUES TO EACH OTHER AND MAKE DUPLICATE VALIDATION
if((value1.pt === value2.pt) && (value1.pm === value2.pm) && (value1.sn === value2.sn)){
// HERE DUPLICATE ELEMENT FOUND
console.log(value1.pt);
console.log(value2.pt);
console.log(value1.pm);
console.log(value2.pm);
console.log(value1.sn);
console.log(value2.sn);
alert('asd');
}
});
});
On Click on add button it is very easier for me to only add unique set of values, but if user have rights to change values after adding into the list, so how do i check duplication on click of "NEXT" button ?