Forum: Ruby on Rails Update href, on drop down menu selection change

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.
A1d22dc1d2a1a1842c83a90e70199345?d=identicon&s=25 Dimitris Zavaliadis (dimzava)
on 2007-07-19 10:25
Hi there,

I have a drop down menu that looks like this:

<select id="results_per_page" name="results_per_page"/>
   <option value="10">10</option>
   <option value="15">15</option>
   <option value="20">20</option>
   <option value="25">25</option>
   <option value="30">30</option>

I also have some links that need to take dynamically the value of the
option selected in the above drop down menu, so that this value can be
passed as a parameter to my rails application, when the user clicks a
link. For example, my links look like these:

<a href="/person/list/?country=foo&results_per_page=[variable that
should change whenever a different option is selected]#results">Foo

<a href="/person/list/?area=bar&results_per_page=[variable that should
change whenever a different option is selected]#results">Bar Area</a>

<a href="/person/list/?language=en&results_per_page=[variable that
should change whenever a different option is

What I would like to achieve, is dynamically updating the value of the
"results_per_page" parameter in those links, whenever the user selects a
different option from the drop down menu. So, for example, when the page
is first loaded, the value of the variable will be '10' and then when
the user selects, say, option '20', this variable will be updated
dynamically to '20'.
This way, when one of the above links will be clicked, the right
parameter value will be passed to my rails app.

I've tried using plain old JavaScript with 'onchange' as well as Ajax
with an rjs template, to no avail. Any ideas??

Many thanks in advance,
This topic is locked and can not be replied to.