php - ajax updating a class element -


i have shopping cart list of items in cart array. when 1 removed, updates cart through ajax, item number in array, each shopping cart item, not update unless page refreshed.

<input class="remove_cart_id" type="hidden" value="'.$i.'" /> 

the $i indicates number in array. if item removed, effect order of array, want update $i each class.

rather having output entire cart contents, there easy way update element each class. done quite easily, $i = 0, , i++ each item in shopping cart array.

update:

$('.remove_cart_item').click(function(){ $(this).parent().stop(true, true).fadeout(); var pid = $('.remove_cart_id', this).val(); $.ajax({             type    : 'post',     url     : 'ajax/remove-cart.php',     data    : 'pid='+pid,     success : function(data) {         $('#cart_quantity').html(data);     } }); // update cart array var = 0;  $('.remove_cart_id').each(function(){      $(this).val(i);      i++;  }; 

});

i using code now, there seems sort of bug each function, code stopped working.

to change values based on class, try

$(".classname").each(function() {    $(this).val('change'); }); 

class applies multiple elements being group together. if have element in same class, value change applied well.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -