My table Looks like this:
<table style="width:100%" class="table table-striped table-bordered" id="xxxxxx">
<thead>
<tr>
<th>Item Id</th>
<th>Item Name</th>
<th>Rate</th>
<th>Quantity</th>
<th>Total</th>
<th>Edit</th>
</tr>
</thead>
</table>
I am adding data to my table on a button click like this:
var item_x = $('#itemIdx').val();
var item_x_name = $('#itemx option:selected').val();
var rate_x = $('#ratex').val();
var quantity_x = $('#quantityx').val();
var total_x = rate_x * quantity_x;
var add_to_table = '<tr><td>' + item_x + '</td><td>' + item_x_name + '</td><td>' + rate_x + '</td><td>' + quantity_x + '</td><td>' + total_x + "</td><td><buttonDelete</button></td>";
$('#xxxxxx').append(add_to_table);
Now While adding data dynamically I want to duplicate data based on item_x value whether it is repeated or not. If repeated then an alert is to be shown; if not simply add to the xxxxxx to table.