There is a piece of code where blocks appear in the for loop, as well as inside another for loop that displays the values of the option and value fields. When adding a product, only the first value is taken, that is, you select, for example, 6, press "add to cart", and the figure 1 always comes.
$(document).ready(function(){ $('.name a').click(function(){ $this = $(this); var id = $this.parent().find('select').attr('id'); var count = $this.parent().find('option').val(); alert(count); $.ajax({ type: 'POST', url: 'post.php', data: {itemid: id, count: count}, success: function(data){ $this.parent().find('.add').html('Товар добавлен!'); } }); }); }); <?for($i = 1; $i <= 9; $i++){?> <div id="wripper"> <div class="name"> Товар №-<?=$i?> <img src="images/img.png" alt=""> <select id="item<?=$i?>"> <?for($q = 1; $q <= 9; $q++){?> <option value="<?=$q?>"><?=$q?></option> <?}?> </select> <a href="javascript:void(0);">Добавить товар</a> <div class="add"></div> </div> </div> <?}?>