0
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 one to delete the record and each button also has the attribute data-id=NUMERO DO ID
.
What I want is that when the user clicks on the change button, know how to get the information of the fields senhaA
and nivelA
in accordance with their respective data-id=NUMERO DO ID
Maybe this will help: https://jsfiddle.net/2pmn1ems/3/, https://answall.com/questions/130803/passar-id-de-um-dado-de-uma-tabela-para-a-modal
– Miguel