Thanks, I somehow got it fixed using observe_field. But, I'm not sure if
its the right way in the scenario which is like: One combo box with name
of location is on the top and when ever I change the location the combo
box underneath will be updated with the areas within the location
selected in the top combo box. With this bottom combo box there are few
other text boxes as well where some input is given. At the bottom is a
button "proceed to next area" when clicking which a new combo box with
the similar text fields gonna add to the bottom of that updated combo
box with the next area name. This keeps on until the end of the list is
reached. Ok this is similar to what I'm trying to make:

https://www.epa.qld.gov.au/parks/iaparks/gds/IAGDS450.jsp

Here's how got the first part sorted which is updating bottom combo with
the top combo:

IN CONTROLLER:
--------------------------------------------------------------------------------
class UserController < ApplicationController
  def index
  end
  def update_campsites
    @campholder=[]
    id=params["walk_id"]
    @camps=Campsite.find_by_sql("select camp_location from campsites
where walk_id="+id)
    for eachcamp in @camps
      @campholder << [eachcamp.camp_location, eachcamp.camp_location]
    end
  end
end
--------------------------------------------------------------------------------

IN MODEL: (loads great walks locations)
--------------------------------------------------------------------------------
class GreatWalk < ActiveRecord::Base
  def self.getAvailableLocations
    @locations=GreatWalk.find(:all)
    @locationsholder=[]
    for eachlocation in @locations
      @locationsholder << [eachlocation.location,eachlocation.id]
    end
    @locationsholder
  end
end
--------------------------------------------------------------------------------

IN MODEL: (loads campsite locations)
--------------------------------------------------------------------------------
class Campsite < ActiveRecord::Base
  belongs_to :great_walk
  belongs_to :fee
  has_many :customer_bookings
  def self.getAvailableCamps
    @campsholder=[]
    @camps=Campsite.find(:all)
    for camp in @camps
      @campsholder << [camp.camp_location, camp.id]
    end
    @campsholder
  end
end
--------------------------------------------------------------------------------

IN VIEW: (index.rhtml)
--------------------------------------------------------------------------------
<h1>Great Walks Online Booking</h1>
<form>
  <%= select(:selected, :id, GreatWalk.getAvailableLocations, {:prompt
=> 'Select a category'}, :id => :id_selected) %>

  <%= observe_field :id_selected, :url => {:action =>
:update_campsites}, :update => :campsites, :with => "walk_id" %>
</form>
<div id="campsites">
  <form>
    <%=select "selected","camp","Please select location first:"%>
  </form>
</div>
--------------------------------------------------------------------------------

IN VIEW: (update_campsites.rhtml)
--------------------------------------------------------------------------------
<%form_tag do %>
    <p>
      <label for="camp location">Campgroud</label>
      <%=select "selected","camp",@campholder%>
    </p>
    <p>
      <label for="arrival date">Arrival Date</label>
      <%=text_field_tag :name, params[:name]%>
    </p>
    <p>
      <label for="nights">Nights</label>
      <%=text_field_tag :nights, params[:nights]%>
    </p>
    <p>
      <label for="parents">Parents</label>
      <%=text_field_tag :parents, params[:parents]%>
    </p>
    <p>
      <label for="children">Children</label>
      <%=text_field_tag :children, params[:children]%>
    </p>
    <%=submit_tag "Calculate"%>
<%end%>
--------------------------------------------------------------------------------

PLZ any ideas on how can I achieve similar... thanks.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to