Dynamic url with javascript? - Help Please

Hi,

I’m trying to call a remote function when a combobox option is selected,
passing as an argument the current value of the combobox (paramenter
“panel_id”:

As you can see in this example, the :panel_id value is hardcoded…
¿How can I get the value of the combobox dynamically??? I’ve tried by
replacing the hardcoded value with javascript, but it’s being passed as
a string to the controller, so the paramenter doesn’t work.

Help Please.

Thanks everybody.

Try using observe_field()… there are a couple good posts about this.

http://www.adamhegedus.com/articles/2006/01/19/ajaxed-select-boxes-in-rails
http://www.roryhansen.ca/?p=9

Jason C. wrote:

Try using observe_field()… there are a couple good posts about this.

http://www.adamhegedus.com/articles/2006/01/19/ajaxed-select-boxes-in-rails
http://www.roryhansen.ca/?p=9

Thanks a lot for your help!

That’s what I was looking for.

Matias S. wrote:

Jason C. wrote:

Try using observe_field()… there are a couple good posts about this.

http://www.adamhegedus.com/articles/2006/01/19/ajaxed-select-boxes-in-rails
http://www.roryhansen.ca/?p=9

Thanks a lot for your help!

That’s what I was looking for.

Eh, you can do it without observe_field. I prefer not to since there is
a slight delay and the extra messiness to deal with. Try this…

<select id=“server_interface_jack_switch_panel”
onchange=“<%=remote_function(:update=>‘server_interface_jack_switch_id’,:url=>{:action=>‘update_jack_option’},
:with => “‘panel_id=’+value”)%>”>

Kevin O. wrote:

Eh, you can do it without observe_field. I prefer not to since there is
a slight delay and the extra messiness to deal with. Try this…

<select id=“server_interface_jack_switch_panel”
onchange="<%=remote_function(:update=>‘server_interface_jack_switch_id’,:url=>{:action=>‘update_jack_option’},
:with => “‘panel_id=’+value”)%>">

mmm… i didn’t realise that the :with parameter could be used with
remote_function… cool…

anyway, if you omit the :frequency parameter in observe_field (that’s
what I’m doing) the function fires with the “onchange” event, so, no
delay exists…

Thanks,