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.
C7d5bc5b054035d95f287797c2595694?d=identicon&s=25 Matias Surdi (Guest)
on 2006-02-07 17: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.
Abdf9626d4bdacbe16703056e37215d5?d=identicon&s=25 Jason Cartwright (Guest)
on 2006-02-07 17: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
C7d5bc5b054035d95f287797c2595694?d=identicon&s=25 Matias Surdi (Guest)
on 2006-02-07 18:07
(Received via mailing list)
Jason Cartwright 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.
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (olbrich)
on 2006-02-07 18:13
Matias Surdi wrote:
> Jason Cartwright 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")%>">
C7d5bc5b054035d95f287797c2595694?d=identicon&s=25 Matias Surdi (Guest)
on 2006-02-08 12:40
(Received via mailing list)
Kevin Olbrich 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.