0
Guys, I’m banging my head on something:
There is an HTML code, which makes a form. In this form there is an answer that I can choose from yes and nay. The answer below this, provides a field, IF you put yes in the above answer, as justification.
What I want to do: I want to create a function in the JS that when I select the yes this field appears, and in case I put nay he remains hidden.
My doubt: How do I use the JS? How do I use the onClick
? I want to know which variables I place and how I can make this code, if I put the id of the yes and of nay, how I build?
I’m sorry for any doubts
I saw something like:
<script>
const radio = document.querySelectorAll(".radioButton");
const "element" = document.("");
radio[0].addEventListener("click", function() {
"".style.display = "block";
});
radio[1].addEventListener("click", function() {
"".style.display = "none";
});
</script>
But I don’t know where I put each thing.. for example, what I want to hide, where I put in the code, id or name.. where I put each thing
If, any of the answers below solved your problem mark as accepted.
– user170164