How to show different dropdowns by choice
I want to show different dropboxes to user by its own choice.
example;
Dropbox1;
1-> Apple 2-> Bluberry
when user choose choice 1 it`ll show
1a -> Apple Juice 1b -> Apple
when user choose choice 2 it`ll show
2a -> Blueberry Juice 2b -> Blueberry开发者_运维问答
Whenever I have to create such a thing, I'll create a multidimensional array. For example: [ ["Blueberry", "Pie"], ["Apple", "Pie"], ["Lemon", "Pie"] ]
Then in the first dropdown I set an onchange action to a function that checks which ID is selected, if for example ID 1 is selected, I'll get the array at index 1, in this example being ["Apple", "Pie"].
Then I'll empty the second dropdown and loop through the array to generate new options and place them in the body of the second dropdown.
精彩评论