Forum: Ruby on Rails form_remote_tag - Mulitple actions based on user selection

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
365aa622f1dccc5efa83b041f68ad98b?d=identicon&s=25 marike1 (Guest)
on 2005-11-12 12:49
(Received via mailing list)
I've been searching all of the various Rails lists, and this question
has come up, but can't implement any solution so far.

I have a form that allows the user to search Amazon.  Using Ian
MacDonald's excellent Ruby/Amazon Library, there are different types
of searches the user can perform.

I use a select menu to change the search type and I can change
actions with a simple line of Javascript like so:

<form method="post" action="search_artists">
   <select onchange="document.forms[0].action = options
   <option value="search_artists" selected>Music</option>
   <option value="search_books">Books</option>
   <option value="search_actors">DVD</option>

However, I want to use either form_remote_tag or something like this:

<%= submit_to_remote("search", "Search",
                    :url => {:controller => "search", :action =>
                    :html => {:class => 'search'},
                    :update => :item,
                    :method => 'get') %>)

<div id="item"></div>

Both of which work perfectly, as the results which I display with a
three different partial templates, are returned without page refresh.

However, in doing so, I am forced to hard code the :action of
submit_to_remote, thereby, disabling the line of javascript in the
select menu.  Duh.

So after lurking on this list, enjoying the wealth of info
contributed by DHH and all the talented programmers.   Any ideas.  I
remember reading on one list about possibly using observe_field to
listen for user events, and somehow update the action.    Thanks in
advance for any help you may offer, because at this point I am stumped.

Markus Arike
This topic is locked and can not be replied to.