Hello.
There is a page that displays the result of the search, a php fragment script, which forms the rows in the table:
while ($row_result_material_name = mysqli_fetch_array($search_material_name)) { echo "<tr>"; echo "<td class='col-md-'>",$row_result_material_name['idPositionFK'],"</td>"; echo "<td>",$row_result_material_name['title'],"</td>"; echo "<td>",$row_result_material_name['price']," руб.</td>"; echo "<td>",$row_result_material_name['unit'],"</td>"; echo "<td> <button id='", $row_result_material_name['idMaterial'] ,"' data-id-material='", $row_result_material_name['idMaterial'] ,"' type='button' class='btn btn-success btn-md btn-wd' data-original-title='' title=''> <i class='material-icons'>add</i> </button> </td>"; echo " <script> $('#",$row_result_material_name['idMaterial'],"').click(function(){ var idMaterial_to_add = $('#",$row_result_material_name['idMaterial'],"').data('id-material'); $.ajax({ url: 'server/express-order/express-add-to-plan.php', type: 'POST', cache: false, data: {'idMaterial_to_add':idMaterial_to_add}, dataType: 'html', success: function(data) { } }); </script> "; echo "</tr>"; } Output result:
By virtue of my poor knowledge of js, I add a add script to each button, which adds a position to the plan (you can call the list / basket as you like).
I ask you to suggest how best to write a single handler for pressing the position buttons in the table.
I suspect that this is somehow related to the magic of this in js.
Thank!
