-1
I’m having a hard time doing something that apparently should be very simple, I need a file type input to be disabled/invisible until the user marks a checkbox type input that by default will be disabled.
Here is my attempt:
function HabilitarUpload(Opcao1, UploadOpcao1)
{
document.getElementById(UploadOpcao1).disabled = !Opcao1.checked;
}
<label class="container">OPÇÃO 1
<input type="checkbox" id="Opcao1" onclick="HabilitarUpload(Opcao1, UploadOpcao1);">
<span class="checkmark"></span>
</label>
<p>TEXTO UPLOAD OPÇÃO 1
<input type="file" name="img" id="UploadOpcao1" disabled="true">
</p>
I would also like to know if/how I could make the text that comes before the file type input (TEXT UPLOAD OPTION 1) appear only when the checkbox is checked.
Did you like the answers? The best way to thank those who helped you is to mark "accept" the best answer and vote for all that helped you. So you make sure that whoever wrote the answer gets something in return, in addition to making the site cleaner and more useful for everyone.
– Jorge B.