I have the following table:
<tr>
<td>FULANO 1</td>
<td>USUARIO 1</td>
<td>
<input type="text" data-id="1" class="form-control" id="senhaA" size="6">
</td>
<td>
<select class="form-control" data-id="1" style="width:auto;" id="nivelA">
<option value="0">Desativado</option>
<option value="1">Digitador</option>
<option value="2">Administrador</option>
</select>
</td>
<td>
<a href="#" id="atualizar" data-id="1" class="btn btn-primary">Atualizar</a>
</td>
<td>
<a href="#" id="excluir" data-id="1" class="btn btn-danger">Excluir</a>
</td>
</tr>
<tr>
<td>FULANO 2</td>
<td>USUARIO 2</td>
<td>
<input type="text" data-id="2" class="form-control" id="senhaA" size="6">
</td>
<td>
<select class="form-control" data-id="2" style="width:auto;" id="nivelA">
<option value="0">Desativado</option>
<option value="1">Digitador</option>
<option value="2">Administrador</option>
</select>
</td>
<td>
<a href="#" id="atualizar" data-id="2" class="btn btn-primary">Atualizar</a>
</td>
<td>
<a href="#" id="excluir" data-id="2" class="btn btn-danger">Excluir</a>
</td>
</tr>
It follows a pattern where each line receives attributes data-id=NUMERO DO ID
At the end of each line there are two buttons: one to change the data and another to delete the record, and each button also has the data-id=NUMERO DO ID
attribute.
What I want is that when the user clicks the change button, I know how to get the information from the senhaA
and nivelA
fields according to their data-id=NUMERO DO ID