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

Asked

Viewed 129 times

0

Good afternoon, I have a table that has a column with an input radio, I need to read the values of each row of an input radio without interfering in the order of the lines. Example, I have 3 lines and selected only the radio of the last line, I need to return the function the value of the radio button in the third time I read it. I tried to use Document.querySelectorAll('input[type=radio]:checked')[Indice]. value however the problem is that it sorts by selected radio Buttons. Then in the scenario I explained he returned first the radio button selected 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.

1 answer

0

I found the answer.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.