Forum: Ruby on Rails Dynamic url with javascript? - Help Please

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Matias S. (Guest)
on 2006-02-07 18:33
(Received via mailing list)
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":

<select id="server_interface_jack_switch_panel"
onchange="<%=remote_function(:update=>'server_interface_jack_switch_id',:url=>{:action=>'update_jack_option',
:panel_id=>'1' })%>">


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.
Jason C. (Guest)
on 2006-02-07 18:54
(Received via mailing list)
Try using observe_field()... there are a couple good posts about this.

http://www.adamhegedus.com/articles/2006/01/19/aja...
http://www.roryhansen.ca/?p=9
Matias S. (Guest)
on 2006-02-07 19:07
(Received via mailing list)
Jason C. wrote:
> Try using observe_field()... there are a couple good posts about this.
>
> http://www.adamhegedus.com/articles/2006/01/19/aja...
> http://www.roryhansen.ca/?p=9

Thanks a lot for your help!

That's what I was looking for.
Kevin O. (Guest)
on 2006-02-07 19:13
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/aja...
>> 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")%>">
Matias S. (Guest)
on 2006-02-08 13:40
(Received via mailing list)
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,
This topic is locked and can not be replied to.