Hi, my target (by button click) is check if in a table there is an Item: if yes I would like to add +1 in my quanty if no I add a new row.
I'm able to check if there is the Item value in the table, and I'm able to add a new row if there is the ItemValue, but I'cant add a +1 in the quantity if the item is in the table.
my code:
- $('.comanda-button').click(function(){
- label_btn=$(this).attr("value");
- id=$(this).attr("id");
- $('#conto tr').find('td:first-child').each(function() {
- test=$(this).text();
- if(test===id){
- trovato='1';
- qta=$('td:eq(2)').text();
- qta=parseInt(qta)+1;
- $('td:eq(2)').text(qta);
- return false;
- }
- });
- if(trovato==='0'){ //add a new row
- $("#conto").find('tbody').append(''+id+''+label_btn+''+qta+'');
- trovato='0';
- } });
#conto is the id of the table.
With this code I change the vale of the first row and did not work the istruction qta=parseInt(qta)+1;
thanks