'How to show/hide a textarea based on multiple radiogroups selection?
I'd like to show 1 specific textarea, whether is the first group of radios that is selected as "not okay", the second group, or if both are selected as "not okay".
I tried using this method.
const inputBox = document.querySelector('#textarea');
inputBox.style.display = 'none';
function hideShowJacks(event)
{
const selectValue = event.target.value;
if (selectValue === 'nok')
{
inputBox.style.display = 'block';
}
else
{
inputBox.style.display = 'none';
}
}
I used the onclick attribute on both radio groups thinking that I would behave correctly, and it kinda does. But for example, If the first radio is selected as "Not Okay" (the textarea is shown), but after that I select the "Okay" option in the second group of radios, the textarea disappears, even though I selected the first one as "Not Okay".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
