Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Zachary Pearson](https://secure.gravatar.com/avatar/19dd87af73123976971720722a621dc1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zachary Pearson
9,578 PointsRails apps: Displaying items based on user input
Hi all,
This is a fairly vague question - not looking for a concrete answer as much as a push in the right direction. I've been googling around and haven't been able to get closer to what I'm looking for.
I'm working on a rails app that has a main page that displays a collection of documents in a table. Each document has several parameters: title, subject, author, those sorts of things. By default, the table shows the documents in reverse chronological order by time of creation.
What I'd like to have is a collection of drop down menus up above that allow users to sort documents by one (or many) of these fields. So, for example, selecting a certain author and a certain subject would cause the table to only display documents that match both those parameters. Ideally, I'd want to accomplish this without loading a new page.
I know this is very non-specific, but anyone have any leads?
2 Answers
![Tim Knight](https://secure.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Tim Knight
28,888 PointsHey Zachary, I think you're solution here might be doing something with JavaScript and AJAX. If for example you were using jQuery you could write something that would check onchange of those selects that would pass a query parameter to a $.get request, get the data back and load it in a div that contains your results. It's not necessarily a Rails or Ruby specific issue.
That being said, there might be a jQuery or Rails plugin for chaining your select options together too if you want the options in the select fields to change based on the other selections. Here is a jQuery plugin that might help if you're wanting to do something like specifically. http://www.appelsiini.net/projects/chained
I hope that gives you some direction.
![Zachary Pearson](https://secure.gravatar.com/avatar/19dd87af73123976971720722a621dc1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zachary Pearson
9,578 PointsThanks - that actually helps a lot! Like I said, I wasn't even quite sure where to start looking. I'll start looking into a JavaScript solution and follow up on those forums if I have any trouble.