简体   繁体   中英

How to unhide another select field when one option is selected from the first?

I have the following problem. I have a form where I have a select field for categories. When I pick a category I want to show another select field below that one where all subcateries for the selected category shows in it. I have two models for categ's and subcateg's but I also found the ancestry gem. Both are ok. Thanks

If you are using the Ancestry gem, then the Railscast "Auto-Complete Association" should give some helpful points as well as this question/answer.

You should be able to modify what is given in these links to suit your needs, ie you can take the call which would make the autocomplete results, and then build that into your select field. This would also all be wrapped in an AJAX call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM