Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

想請教一下,如果我想讓表單有兩種不同的選擇內容,應該怎麼做? #35

Closed
afgnsu opened this issue Oct 6, 2015 · 2 comments

Comments

@afgnsu
Copy link

afgnsu commented Oct 6, 2015

如題,我想寫一個房仲網站,例如有房屋和土地兩種項目,這個檔案在 app/views/items/_form.html.erb

<%= f.select :kind, [['房屋',0],['土地',1]], include_blank: true, label: '項目' %>
<%= f.select :category, [['大廈',0],['透天',1],['公寓',2],['建地',3'],['農地',4],['工業地',5]], label: '分類' %>

當『新增』物件時,我希望選完項目後,若選擇『房屋』時可以只出現房屋的分類 (例:大廈、透天、公寓),選『土地』時可以只出現土地的分類(例:建地、農地、工業地)。

請問該如何修改?是否一定要搭配 jQuery 的 append?

@zackexplosion
Copy link
Member

我希望選完項目後

有這個動作就一定要搭配 Javascript 來做了 ,除非你要帶參數給後端讓他重新宣染整個頁面。

@afgnsu
Copy link
Author

afgnsu commented Oct 6, 2015

收到,謝謝 ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants