Dynamically Generate a Selection List in a Rails Template (Page 1 of 4 )
Hack 58 Generate a selection list from server-side data using Ajax and Ruby on Rails.
This hack has the same behavior as some of our earlier hacks, but the path our code takes to produce its effects is quite different. A Rails application wraps all of theXMLHttpRequestmechanics behind its own methods. Figure 7-9 shows what the web page looks like. The user reaches this page by typing http://localhost:3000/hacks/ into a web browser’s location field.
We’re using the WEBrick server that comes with Ruby on Rails.
Figure 7-9.Cop your own pop-up
The user chooses either Team or Individual from the pop-up and clicks the Show Sports button, and anotherselectlist (whose values are determined by the user’s choice in the first list) appears just above the button.