Here''s an example:
On the original form you''d have something like:
<div id="makes">
<%= select("search", "make",
Make.find(:all).collect {|m| [m.name, m.id] },
:include_blank => true) %>
<%= observe_field("search_make",
:update => "models",
:url => { :action => "search_models" },
:with => "''make_id=''+value") %>
</div>
<div id="models">
</div>
Then, inside your target action (search_models.rhtml in this case):
<%= select("search", "model", @models.collect {|m|
[m.name, m.id] },
:include_blank => true) %>
Also see:
http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#M000402
Hope this helps.
On 8/13/05, Oliver Legg <lists-XiLho7JcZycsV2N9l4h3zg@public.gmane.org>
wrote:> I''m trying to use rails built in AJAX support in my application,
it
> works fine while using it on a text field, but fails when trying to
> use it on a select field.
>
> When the select box is changed I want it update a div in my form. Is
> there a way to do this using built in rails helpers and how do i do
> this with select boxes.
>
> Thanks in advance.
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>