+ 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 .
5 odpowiedzi
+ 1
Can we see the code?
+ 1
You have to make them false again
https://code.sololearn.com/WBTPzx3GE3sZ/?ref=app
Btw, next time just share the link 😉
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>
0
oh I didn't know that i could do that, thanks
0
No problem.
Happy coding 😉