0
Hello, I have a table that has a line where you can select a radio button. When selecting the save button I want to get the values that were selected. I can pick up the radio button text, however I’m not getting the selected value.
enter the code
var table = document.getElementById("tbl");
for (var i = 1,row; row = table.rows[i]; i++) {
rows = table.getElementsByTagName('tr');
var cells = rows[i].getElementsByTagName('td');
alert(cells[2].innerText);
}
<tr>
<td>
<label>
Presente
<input type="radio" name="@item.Id" value="1" checked>
</label>
<label>
Ausente
<input type="radio" name="@item.Id" value="0">
</label>
<td/>
</tr>
Document.querySelectorAll('input[type=radio]:checked') returns an array with all selected inputs, iterate using for, while...
– Daniel Leite de Oliveira