I have a table where I have a checkbox to enable the editing of several items at the same time, that is, I can edit several since the input is selected, but I have a problem that if I want to edit only one does not need to select the checkbox.
function selecionaCompromissos() {
var ids = document.getElementsByClassName('agrupaPagto');
gravaArray(ids);
}
function gravaArray(dados) {
var array_dados = dados;
var teste = Array();
var contador = 0;
for (var x = 0; x <= array_dados.length; x++) {
if (typeof array_dados[x] == 'object') {
if (array_dados[x].checked) {
teste[x] = array_dados[x].id;
contador++;
}
}
}
teste = teste.filter(Boolean);
console.log(teste);
}
<table class="table table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th>Nome</th>
<th>Número</th>
<th>Vencimento</th>
<th>Parcela</th>
<th>Valor</th>
<th>Boleto</th>
</tr>
</thead>
<tbody>
<tr>
<td><input class="agrupaPagto" id="10" value="125" name="txtAgrupa" type="checkbox"></td>
<td>Art Pneus</td>
<td><a class="tool_tip" href="#" data-toggle="tooltip" title="2">343</a></td>
<td>10/10/2017</td>
<td>2 <b>de</b> 2<span style="color: red"> </span></td>
<td>R$ 125,00</td>
<td style="color:red; font-weight: bold;">Em aberto <span class="badge"><a href="#" data-toggle="modal" data-target="#modal_compromissos" onclick="selecionaCompromissos()">Pagar</a></span></td>
</tr>
<tr>
<td><input class="agrupaPagto" id="11" value="221.00" name="txtAgrupa" type="checkbox"></td>
<td>Maria Bonita</td>
<td><a class="tool_tip" href="#" data-toggle="tooltip" title="teste">532</a></td>
<td>18/10/2017</td>
<td>1 <b>de</b> 4<span style="color: red"> </span></td>
<td>R$ 221,00</td>
<td style="color:red; font-weight: bold;">Em aberto <span class="badge"><a href="#" data-toggle="modal" data-target="#modal_compromissos" onclick="selecionaCompromissos()">Pagar</a></span></td>
</tr>
</tbody>
</table>
The application works but has to be selected, but the question is if the user is only editing a row and selecting without the need to mark checkbox
?