I use select_tag to create a selection box in a view and how can I get
the current selection value in its controller? For example:
select_tag:project_selection,options_for_select(@project_names),
:onchange
=>remote_function(:update=>''posts'',:loading=>''false'',
:url => { :action => :update_project_selection })
in the action "update_project_selection", how can I get the current
selection?
thanks,
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Check source code and find <select name="xxx"> The xxx value is what you can access with params[:xxx] -- Good advice: Download Firebug plugin for Firefox, which shows all the communication between page and server, and you''ll see all the POST variables with the values :) On 28. Dec., 14:08 h., Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I use select_tag to create a selection box in a view and how can I get > the current selection value in its controller? For example: > > select_tag:project_selection,options_for_select(@project_names), > :onchange > =>remote_function(:update=>''posts'',:loading=>''false'', > :url => { :action => :update_project_selection }) > > in the action "update_project_selection", how can I get the current > selection? > > thanks, > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
zero0x wrote:> Check source code and find <select name="xxx"> > > The xxx value is what you can access with params[:xxx] > > -- > > Good advice: Download Firebug plugin for Firefox, which shows all the > communication between page and server, and you''ll see all the POST > variables with the values :) > > On 28. Dec., 14:08 h., Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>In this case: select_tag: project_selection,options_for_select(@project_names), :onchange =>remote_function(:update=>''posts'',:loading=>''false'', :url => { :action => :update_project_selection }) the name should be "project_selection", but in its controller I print the params keys: params.keys.each{|k|puts k} there is not such key named "project_selection". -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 28 Dec 2008, at 13:34, Zhao Yi wrote:> > zero0x wrote: >> Check source code and find <select name="xxx"> >> >> The xxx value is what you can access with params[:xxx] >> >> -- >> >> Good advice: Download Firebug plugin for Firefox, which shows all the >> communication between page and server, and you''ll see all the POST >> variables with the values :) >> >> On 28. Dec., 14:08 h., Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > In this case: > > select_tag: project_selection,options_for_select(@project_names), > :onchange > =>remote_function(:update=>''posts'',:loading=>''false'', :url => > { :action => :update_project_selection }) > > the name should be "project_selection", but in its controller I print > the params keys: >You have to tell remote function what to submit, it''s not going to guess for you. This is what the :with option for remote_function is for. Check the docs for link_to_remote for some examples, I''ve got some extra ones at http://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_remote-s-mysterious-parameter too Fred> params.keys.each{|k|puts k} > > there is not such key named "project_selection". > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> You have to tell remote function what to submit, it''s not going to > guess for you. > This is what the :with option for remote_function is for. Check the > docs for link_to_remote for some examples, I''ve got some extra ones at > http://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_remote-s-mysterious-parameter > too > > FredIf I added :with in the select_tag: :with=>"''project_selection=+''XXX" what''s value should I use for the current selection? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I suppose you''re using prototype, so you just need to get the value of
the select box.
$("id-of-the-element").getValue()
On 28. Dec., 15:04 h., Zhao Yi
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Frederick Cheung wrote:
> > You have to tell remote function what to submit, it''s not
going to
> > guess for you.
> > This is what the :with option for remote_function is for. Check the
> > docs for link_to_remote for some examples, I''ve got some
extra ones at
>
>http://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_rem...
> > too
>
> > Fred
>
> If I added :with in the select_tag:
>
> :with=>"''project_selection=+''XXX"
>
> what''s value should I use for the current selection?
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
zero0x wrote:> I suppose you''re using prototype, so you just need to get the value of > the select box. > > $("id-of-the-element").getValue() > > > > On 28. Dec., 15:04 h., Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>How can I send more than one parameters? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
By sending JSON:
{name: value, name1:value1, ... }
in your case
{name: $("id-of-the-element").getValue()}
or something similiar.
On 31.12.2008, at 12:50, Zhao Yi wrote:
>
> zero0x wrote:
>> I suppose you''re using prototype, so you just need to get the
value
>> of
>> the select box.
>>
>> $("id-of-the-element").getValue()
>>
>>
>>
>> On 28. Dec., 15:04 h., Zhao Yi
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
>
> How can I send more than one parameters?
> --
> Posted via http://www.ruby-forum.com/.
>
> >
Vojtech Rinik: Web Developer
vojtech-bIuJOMs36amtuwNREz+D9A@public.gmane.org | +421 670899
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Oh I''m sorry that was probably wrong advice :) Forget about it. I just realized, that you''re sending a http query, which looks like: name=value&name1=value1&... So it''s pretty simple: query = "name="+...+"&name1="+... On 31.12.2008, at 12:50, Zhao Yi wrote:> > zero0x wrote: >> I suppose you''re using prototype, so you just need to get the value >> of >> the select box. >> >> $("id-of-the-element").getValue() >> >> >> >> On 28. Dec., 15:04 h., Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > How can I send more than one parameters? > -- > Posted via http://www.ruby-forum.com/. > > >Vojtech Rinik: Web Developer vojtech-bIuJOMs36amtuwNREz+D9A@public.gmane.org | +421 670899 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---