How to determine the values of dynamically generated input type=number in the bin?

php code:
<?php foreach ($catalog as $catalogItem):?>
 <tr class="item_box">
 <td><h1><?php echo $catalogItem['name'];?></h1></td>
 <td><div class="item_price"><?php echo $catalogItem['price'];?></div></td>
 <td><input type=number id="kol" value="" ></td>
 <td><button class="add_item" data-id="<?php echo $catalogItem['id_product'];?>" data-title="<?php echo $catalogItem['name'];?>" data-price="<?php echo $catalogItem['price'];?>">add to order</button></td></tr> 
 <?php endforeach; ?>

a piece of js:
addToCart: function(e) {
 itemData = $(this).data();
 if(typeof === 'undefined') {
 console.log('Missing item ID');
 return false;
 cartData = actions.getStorage() || {};
 if (cartData.hasOwnProperty( {
 cartData[].count = parseInt(cartData[].count)+parseInt($('#Col').val());
 } else {
 itemData.count = $('#Col').val(); 
 cartData[] = itemData;
 if(opts.openByAdding) {
 return false;

The first product is added to and changed the number as expected, but the following go with the number from the first input to have the same id. If the record id to a variable
id=""whereas to obtain the value for each item ?
I would be grateful if someone can guide on the right path .
March 19th 20 at 08:23
1 answer
March 19th 20 at 08:25

Find more questions by tags JavaScript