+ 1

javascript

I created a javascript code to disable a input text field when an option is selected but the input field stay disabled after I change the option. I will be grateful if someone helps me .

18th Mar 2022, 2:55 PM
Arafet alaya
Arafet alaya - avatar
5 ответов
+ 1
Can we see the code?
18th Mar 2022, 2:56 PM
Brain & Bones
Brain & Bones - avatar
+ 1
You have to make them false again https://code.sololearn.com/WBTPzx3GE3sZ/?ref=app Btw, next time just share the link 😉
18th Mar 2022, 3:01 PM
Brain & Bones
Brain & Bones - avatar
0
here is my code: ****************************************************** function func1(){ if(document.getElementById('1').selected){ document.getElementById("A").disabled = true; } else if(document.getElementById('2').selected) document.getElementById("B").disabled = true; } ********************************************************** <label>Nationnalité</label> <select id="mySelect" onchange="func1()" > <option value="">--Veuillez choisir une option--</option> <option id="1" >Tunisienne</option> <option id="2" >etrangére</option> </select> <br> <label>N°CIN</label> <input type="text" id="A" /> <br> <label>N°Passeport</label> <input type="text" id="B" /> <br>
18th Mar 2022, 2:58 PM
Arafet alaya
Arafet alaya - avatar
0
oh I didn't know that i could do that, thanks
18th Mar 2022, 3:04 PM
Arafet alaya
Arafet alaya - avatar
0
No problem. Happy coding 😉
18th Mar 2022, 3:09 PM
Brain & Bones
Brain & Bones - avatar