Currently, I am attempting to display two input boxes in a table when I select specific radio buttons and hide them if I choose another option. The code I have does work but has a minor issue,
function disappear() {
document.getElementsByClassName("table-custom3")[0].style.display = 'none';
}
function appear() {
document.getElementsByClassName("table-custom3")[0].style.display = 'block';
}
<table>
<tr>
<td class="table-custom2">
<input type="radio" id="present" name="attendance" onclick="appear()" /</td>
<td class="table-custom2 "><input type="radio" id="absent" name="attendance" onclick="disappear()" /</td>
<td class="table-custom3 "><input type="time " class="input-xsmall "></td>
<td class="table-custom3 "><input type="time " class="input-xsmall "></td>
</tr>
</table>
The issue with this code is that it only applies to the first user input. I attempted to change from getElementById
to getElementsByClassName
, but only one textbox appeared. Is there a solution for this problem?
I also came across a Jquery code that seems simpler to execute, but I couldn't find a tutorial on how to apply it to my situation. Any advice on that would be greatly appreciated.