Hello all,
I’m very new to Ruby and web programming at all. I’m trying to get a
page where I can have a series of drop downs that are all columns within
the main table of my database. When you drop one down, and select a
value, I want the others to update with their possible options based on
the first selection. For example, the model is employees:
If you use the drop down for ‘title’, and select Vice President, then in
the rest of the drop downs, the only options will be related to those
who are VPs. I hope this makes sense. I just got the collection_select
to populate on my view, but I don’t know where to go from here or how to
pass that value back to a controller function.
I’ve read several blog posts and books, but they don’t’ seem to be
addressing exactly what I’m doing. THANKS!
I think you need AJAX here to populate the cascade “rest of the drop
downs” or refresh the whole page on change of the first drop down and
feed the collection_seelct in the controller with appropriate data.
I think you need AJAX here to populate the cascade “rest of the drop
downs” or refresh the whole page on change of the first drop down and
feed the collection_seelct in the controller with appropriate data.
Damn,
I was hoping I wouldn’t have to do that. I know there is some AJAX that
is included with ROR, anyway to envoke that her? How about an easier
one - once I have selected my value in a collection_select, what do I do
next - how do I pass that selected value back into a controller for
another page - with the results based on that one dropdown box?
I think you need AJAX here to populate the cascade “rest of the drop
downs” or refresh the whole page on change of the first drop down and
feed the collection_seelct in the controller with appropriate data.
Damn,
I was hoping I wouldn’t have to do that. I know there is some AJAX that
is included with ROR, anyway to envoke that her?
Don’t. Learn to write JavaScript properly before you try to have Rails
automate it.
(Hint: proper JavaScript is not mixed in with HTML.)