+ 3
How can I set the default value for an option in <select>?
How can I set the default value for an option in <select> when i select one option from first drop down selection then that collection of selected option bring to second drop down selection.i want to show one default option. https://code.sololearn.com/WgPRxFwWApe8/?ref=app
6 Answers
+ 2
thanks alot for your suggestion,i hope this method worksđ
+ 1
Oh sorry I didn't understand exactly what you meant. You can use Javascript to add the 'selected' attribute to an option of the 2nd dropdown after the user has clicked on the 1st one like this:
document.getElementByID("opt1").selected = "true";
This will work only if the option you want to mark as default has an id of 'opt1'.
I have never tried it before, but I suppose it will work.
Update: I saw your code and it is very interesting. Good luck with fixing it!
+ 1
M E(biologist) You 're welcome!
0
You can add the 'selected' attribute to the option you want to make default. This way, the option will be preselected.
0
when i click to option in first drop down selection i want to show default option in second drop down selection but this way that you say dont work.