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 Cartwright
2006-Feb-07 16:54 UTC
[Rails] Re: Dynamic url with javascript? - Help Please
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 Cartwright 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=9Thanks a lot for your help! That''s what I was looking for.
Kevin Olbrich
2006-Feb-07 17:13 UTC
[Rails] Re: Dynamic url with javascript? - Help Please
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/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")%>"> -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich wrote:> 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/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")%>"> > >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,