0
I have a table HTML and I need to take the values of value='1' data-chkIdProcessamentoDiario='1' data-chkIdRegistro='1'
and assign in an array, but the problem is that apparently the each
does not travel table html, although the browser log shows otherwise:
Boon:
<input class="btn btn-primary downloadPDF" value="Download PDF" type="button" id="BbtnDownloadPDF" />
Button event:
$(document).on('click', '.downloadPDF', function (e) {
e.preventDefault();
var dados = [];
var i = 0;
var table = $('.grid > tbody');
table.find('tr').each(function () {
var _idprocessamentodiario = $('.chkProcessamentoDiario').data('chkidprocessamentodiario');
var _idregistro = $('.chkProcessamentoDiario').data('chkidregistro');
var _idservico = $('.download').data('idservico');
dados[i] = new Object();
dados[i]['IdProcessamentoDiario'] = _idprocessamentodiario;
dados[i]['IdRegistro'] = _idregistro;
dados[i]['IdServico'] = _idservico;
console.log(i + ' - _idprocessamentodiario: ' + dados[i].IdProcessamentoDiario + '| _idregistro: ' + dados[i].IdRegistro + '| idservico: ' + dados[i].IdServico);
i++;
});
});
This is the HTML table:
<table class="grid">
<thead>
<tr class="header">
<th scope="col">
</th>
<th scope="col">
<a href="/Documento?sort=EMPRESA&sortdir=ASC">EMPRESA</a> </th>
<th scope="col">
<a href="/Documento?sort=CNPJ&sortdir=ASC">CNPJ</a> </th>
<th scope="col">
<a href="/Documento?sort=CERT+CONJ+RFB%0d%0a&sortdir=ASC">CERT CONJ RFB
</a> </th>
<th scope="col">
<a href="/Documento?sort=CERTIF+FGTS%0d%0a&sortdir=ASC">CERTIF FGTS
</a> </th>
<th scope="col">
<a href="/Documento?sort=CND+D%c3%8dVIDA+ATIVA+DA+UNI%c3%83O&sortdir=ASC">CND DÍVIDA ATIVA DA UNIÃO</a> </th>
<th scope="col">
<a href="/Documento?sort=CND+FGTS&sortdir=ASC">CND FGTS</a> </th>
<th scope="col">
<a href="/Documento?sort=RECEITA+FEDERAL+PESSOA+JUR%c3%8dDICA+-+CNPJ&sortdir=ASC">RECEITA FEDERAL PESSOA JURÍDICA - CNPJ</a> </th>
<th scope="col">
<a href="/Documento?sort=TRIBUTOS+MOBILI%c3%81RIOS%0d%0a&sortdir=ASC">TRIBUTOS MOBILIÁRIOS
</a> </th>
</tr>
</thead>
<tbody>
<tr>
<td><input class='.checkbox-primary .checkbox-info chkProcessamentoDiario' id='chkProcessamentoDiario' name='chkProcessamentoDiario' type='checkbox' value='1' data-chkIdProcessamentoDiario='1' data-chkIdRegistro='1'/></td>
<td><div style='width:100%; height:100%; float:left;white-space:nowrap;'>ENERGIAS RENOVAVEIS S.A.</div></td>
<td><div style='width:100%; height:100%; float:left;white-space:nowrap;'>08.439.659/0001-50</div></td>
<td></td>
<td></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem1' data-IdProcessamentoDiario=1 data-IdRegistro=1 data-IdServico=1><span style='cursor:pointer'>CERTIDÃO POSITIVA</span></a></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem2' data-IdProcessamentoDiario=1 data-IdRegistro=1 data-IdServico=2><span style='cursor:pointer'>Regular</span></a></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem3' data-IdProcessamentoDiario=1 data-IdRegistro=1 data-IdServico=3><span style='cursor:pointer'>ATIVA</span></a></td>
<td></td>
</tr>
<tr class="alt">
<td><input class='.checkbox-primary .checkbox-info chkProcessamentoDiario' id='chkProcessamentoDiario' name='chkProcessamentoDiario' type='checkbox' value='1' data-chkIdProcessamentoDiario='1' data-chkIdRegistro='2'/></td>
<td><div style='width:100%; height:100%; float:left;white-space:nowrap;'>ENERGIAS RENOVAVEIS S.A. 2</div></td>
<td><div style='width:100%; height:100%; float:left;white-space:nowrap;'>08.439.659/0002-31</div></td>
<td></td>
<td></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem1' data-IdProcessamentoDiario=1 data-IdRegistro=2 data-IdServico=1><span style='cursor:pointer'><font color='red'><b>A certidão deve ser emitida para o CNPJ da matriz ? 08.439.659/000150</b></font></span></a></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem2' data-IdProcessamentoDiario=1 data-IdRegistro=2 data-IdServico=2><span style='cursor:pointer'>Regular</span></a></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem3' data-IdProcessamentoDiario=1 data-IdRegistro=2 data-IdServico=3><span style='cursor:pointer'><font color='red'><b>BAIXADA</b></font></span></a></td>
<td></td>
</tr>
<tr>
<td><input class='.checkbox-primary .checkbox-info chkProcessamentoDiario' id='chkProcessamentoDiario' name='chkProcessamentoDiario' type='checkbox' value='1' data-chkIdProcessamentoDiario='1' data-chkIdRegistro='3'/></td>
<td><div style='width:100%; height:100%; float:left;white-space:nowrap;'>EOL HOLDING S.A.</div></td>
<td><div style='width:100%; height:100%; float:left;white-space:nowrap;'>11.594.952/0001-05</div></td>
<td></td>
<td></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem1' data-IdProcessamentoDiario=1 data-IdRegistro=3 data-IdServico=1><span style='cursor:pointer'>CERTIDÃO NEGATIVA</span></a></td>
<td></td>
<td><a href='#' class='download' name='downloaditem' id='downloaditem3' data-IdProcessamentoDiario=1 data-IdRegistro=3 data-IdServico=3><span style='cursor:pointer'>ATIVA</span></a></td>
<td></td>
</tr>
</tbody>
</table>
It became difficult to understand. You want to go through all the rows of the table and add the Infos: processingDiario, record and idservico in an array, that?
– Aline
@Aline he wants to use the event on the button to get all the items that have checkbox marked. Well, at least that’s what I got after I set up his HTML here and looked at the browser. But the question is really hard to understand, especially since HTML is also confused, because the checkbox has value=1 for all items. Therefore, it is not possible to know exactly which checkbox will be checked or not. The only property that differs would be the date-chkIdRegister. Therefore, he must rephrase the question.
– Andrew Paes
@Andrewpaes, is it really? When he wants to take idService by date attribute, everyone is a.download. I think it’s unclear what he wants and how he wants it. = T
– Aline
@Aline is definitely not clear. I would still downvote to request closure because I am using real data that can compromise customers. Therefore, I will give the chance to repeat the question, following this model: https://answall.com/help/mcve
– Andrew Paes
@Andrews Paes what led you to conclude that this data is real ? and if they were real would be public knowledge, because they are data that can be consulted by anyone... I really don’t know why downvote for that reason, since the doubt is very likely from many other people.
– hard123