Hi,
Got a rails application that has a form (new action) with a select with an options value range from 1 to 5. When the users selects one of the options I need to use ruby "build" to build a number of objects depending on what the select value is.
So when the user selects 2 in the select box the following code needs to run:
@rooms = 2.times { @travel.rooms.build }
Also when the users changes this value from 2 to 1 the code needs to be replaced with
@rooms = 1.times { @travel.rooms.build }
Basically I'm having trouble finding a way to setting the value in jQuery and then updating it in the html. Getting the value is no problem, it's how to dynamically change it in the html that's the issue.
Any tips on how to proceed with this?
Thanks, Amund
Edit - Clarification
I need this to happen before the form is submitted.
@rooms = 2.times { @travel.rooms.build }
So any changes to the above needs to happen while the user is on the form page.