qwertyl
qwertyl

Reputation: 87

How to create a rails drop down menu which triggers either a text area or an upload form

I would like to create a rails drop down menu, with two options: "Upload file" and "Write text". When "Upload file" is selected, an upload form will appear on the right hand site. When "Write text" is selected, an text area appears instead.

Thanks a lot!

Upvotes: 0

Views: 292

Answers (1)

maecro
maecro

Reputation: 233

Well there are many ways you could go about this, but I would just display the view as normal (but hide one of the elements to begin with) and attach a jquery event to the drop down menu. You can then show/hide the element within the event handler based on the value selected. Take a look at http://api.jquery.com/change/, http://api.jquery.com/hide/ and http://api.jquery.com/show/ to get started.

Upvotes: 2

Related Questions