mercredi 22 novembre 2017

Rails. Dropdown1 enables Drobdown2 selection using Ruby on Rails

I have two DropDowns (say DropDown1 and DropDown2) in my _form.html.erb. Here is the _form.html.erb's code (Where I need assistance);

  <div class="input-group">
    <%= f.label :flight_id %><br>
    <%= f.collection_select :flight_id, Flight.all, :id, :airline %>
  </div>
  <div class="input-group">
    <%= f.label :seat_no %><br>
    <%= f.text_field :seat_no %>
  </div>
  <div class="input-group">
    <%= f.label :hotel_id %><br>
    <%= f.collection_select :hotel_id, Hotel.all, :id, :hotel_name %>
  </div>
  <div class="input-group">
    <%= f.label :room_no %><br>
    <%= f.text_field :room_no %>
 </div>

Here I want to convert the seat_no and room_no as dependent Drop down lists, dependent on Flight and Hotel respectively. When I select Flight Seats against that Flight should become available in the Seat drop down list, and same logic for the Room drop down list.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire