0

Disable function does not work.

I want that when user select other then other input field enable otherwise be disabled. my code is https://code.sololearn.com/WngJ7e2GJaAR/?ref=app

15th Jun 2018, 4:48 PM
Satish Kumar Sharma
Satish Kumar Sharma - avatar
4 Respostas
+ 1
Edit your line 45 like this: <select name="one" onchange="if (this.value=='other'){document.querySelector('#otherField').disabled=false;} else {document.querySelector('#otherField').disabled=true;}"> Also, You should give the "other" field a unique ID (for example, I used "otherField") PS: You can also use document.getElementById('otherField') instead of document.querySelector('#otherField') 😉
15th Jun 2018, 4:59 PM
777
777 - avatar
+ 1
It didn't worked because you gave id to the wrong element. Remove the id attribute from your select and give it to the input text box at line 59. That will solve your problem!
17th Jun 2018, 7:16 PM
777
777 - avatar
+ 1
thanks
18th Jun 2018, 2:30 AM
Satish Kumar Sharma
Satish Kumar Sharma - avatar
0
I updated code according to your suggestions but problem didn't solve.
16th Jun 2018, 2:28 AM
Satish Kumar Sharma
Satish Kumar Sharma - avatar