I want to add more dropdown options in this file:
http://parseven.com/java_ex.html
Now it has two and I want to make three more. Third option must be dependent on second option and so on. Please advise me. T开发者_如何学JAVAhanks in advance.
Where is the data coming from? I'm not sure which part of the answer you need most:
- You need to add an event handler to the OnChange event of the first dropdown.
- In the event handler, you need to get the data from somewhere (AJAX?)
- Then you need to take the new data and add it to the second dropdown.
Here is basically what you do:
document.getElementById('dropdown1').onchange = yourFunction;
function yourFunction() {
//Here is where you need to get the data
//Then you need to add them to the other dropdown like this:
var dropdown2 = document.getElementById('dropdown2');
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
dropdown2.options.add(optn);
}
精彩评论