Table with Input Radio - I need to read the values of each line

0

Good afternoon, I have a table that has a column with an input radio, I need to read the values of each line of an input radio without interfering with the order of the lines. Example, I have 3 rows and I selected only the radius of the last line, I need the function to return the value of the radio button the third time I read it. I tried to use document.querySelectorAll ('input [type = radio]: checked') [index] .value however the problem is that it sorts through the selected radio buttons. So in the scenario I explained he returned the selected radio button first and then brought undefined

        var table = document.getElementById("tblpergunta");

        for (var i = 1, row; row = table.rows[i]; i++) 
        {
          var CheckListRespostaModel = {
                "PerguntaId": "", "CheckListPendenteId": "", "Observacao": "", "Controle":                 "", "Id" :"",
                "Nome": "", "BytesToString": "", "Extensao": ""
            };
            rows = table.getElementsByTagName('tr');
            var cells = rows[i].getElementsByTagName('td');
            CheckListRespostaModel.PerguntaId =  cells[2].innerText;
            alert(document.querySelectorAll('input[type=radio]:checked')[i - 1]);

        }

in the other two read.

    
asked by anonymous 12.04.2016 / 17:02

1 answer

0

I found the answer.

 if ($('input[name='+ cells[2].innerText + ']:checked') != null) {
        
       ($('input[name='+ cells[2].innerText + ']:checked').val());
}
    
12.04.2016 / 19:12