What’s the simplest way to bind two select elements in a form, such that the second select element has option elements related to the first choice?
Is there a direct method in jQuery?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
After your initial main select, create several select elements. Hide these sub-selects and don’t give them a name attribute but give them a class that is the same as the main select’s values.
Then attach a change event to the main select where the value selected will be the same as the class attribute of it’s corresponding select. Based off the value show the select and give it a name attribute.
Update: I made sure that the sub selects were hidden and that they weren’t given a name each time the main select was changed.