I am doing a little job in jquery. So my problem is when i click on the anchori get the data and display it in a table using append() .
But again click on the same anchor it duplicate the record. but i do not want to duplicate it just increment 1 value.
Php code is
<?php
foreach ($product_data as $prod_items) {
?>
<a href="#"class="list-group-item product" data-name="<?=$prod_items['itemname'] ?>" data-price="<?= $prod_items['sellingprice'] ?>"> <?= $prod_items['itemname'] ?> </a>
<?php {
?>
My code is
$('.product').click(function () {
var name = $(this).attr('data-name');
var price = $(this).attr('data-price');
var qty = 2;
var amount = parseFloat(price) * parseFloat(qty);
$(".cat_table").append('<tr><td>' + name + '</td><td>' + price + '</td><td>' + qty + '</td><td>' + amount + '</td></tr>');
return false;
});
Thank you.