Good day. There is a table with multiple entries. each row of this table has a drop-down list for selecting the parameter we need and a button. When you click on the button, the data gets into the ajax handler. The problem is that in ajax only the very first entry from the drop-down list is sent, and it does not matter which button to press. Here's the php code:
foreach ($sql as $data){ echo '<th><select>'; foreach ($sql2 as $data2){ echo '<option id="ProdID" value="'.$data2["ProdID"].'">'.$data2["ProdName"].'</option>'; } echo'</select></th>'; echo '<th><input type="button" data-old="'.$data['OLDID'].'"data-id="'.$data['id'].'" value="ok" class="button"/></th>'; } Here is my ajax handler:
jQuery(document).ready(function(){ $('.button').click(function(event) { event.preventDefault(); var id=$(this).data("id"); var oldid=$(this).data("old"); var ProdID=$("#ProdID").val();//Данные из выпадающего списка jQuery.post('insert.php, { id:id , oldid:oldid , ProdID:ProdID}, function(data) { alert(ProdID); } ); }); }); Yes, I know that I need to do this through the class, but I do not know how to pass the parameter. I know more precisely, but I only know the transfer of parameters from the button by pressing it.