Get values of buttons that are randomly generated [closed]

1

I need to get the values in the click event of the buttons, which are automatically generated with php . I am not able to do the javascript/jquery function to do this.

Here is the code that generates them:

while ($i != $max)
{
  $i++;
  $con = mysqli_connect("localhost","roberto","","manutencao");
  $query = ("select id,nome from aparelhos where id = ".$i." ");
  $aparelho = mysqli_query($con,$query);
  $fetch = mysqli_fetch_row($aparelho);
  $id = $fetch[0];
  $nome = $fetch[1];
  print "<tr>";
  // IDAPARELHO É O ID QUE PRECISO PEGAR A CADA CLICK NO BOTÃO GERADO COM O FOR
  // VOU PRECISAR ENVIAR ESSE ID PARA O PHP FAZER UMA CONSULTA NO BANCO DE DADOS
  //
  print "<td><button id='IdAparelho' value='".$id."' type='submit' class='btn btn-primary' data-toggle='modal' data-target='#modalVisualizarComponentes' data-index='".$id."' >".$id."</button></td>";
  print "<td><strong>".$nome."</strong></td>";
  print "</tr>";
}
    
asked by anonymous 06.12.2016 / 16:06

0 answers