Skip to content
Advertisement

On changing input using ajax only 1st row works not all

When I try to change the number of quantity and then I want to update the total price according to that…using ajax but only first row works and all others rows does not work. Ajax request is only working for 1st rows not for other rows.

Cart Page :

enter image description here

DB Structure :

enter image description here

cart.php

JavaScript

ajax code

JavaScript

action.php

JavaScript

Advertisement

Answer

Yes, because you use id and it takes element from first row. You should use class instead of id:

  1. id=”pid” change by class=”pid”
  2. id=”itemQty” change by class=”itemQty” etc.

And take element from current row. Something like this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement