Hey all,
I have a select("post", "person_id",
Person.find_all.collect {|p|
[ p.name, p.id ] }) and I would like to submit the value when it is
selected.
I know I have to do something like this:
onchange="<%remote_function(:update => "options",
:url => { :action => :update_options })
but how can I pass it the value of the selected option?
thanx in advance
Pat
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
remote_function(:update => "options",
:url => { :action => :update_options },
:with =>
"''post%5Bperson_id%5D=''+$F(''post_person_id'')")
HTH,
Pratik
On 11/19/06, Patrick Aljord
<patcito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hey all,
> I have a select("post", "person_id",
Person.find_all.collect {|p|
> [ p.name, p.id ] }) and I would like to submit the value when it is
> selected.
> I know I have to do something like this: onchange="<%>
remote_function(:update => "options",
> :url => { :action => :update_options })
> but how can I pass it the value of the selected option?
>
> thanx in advance
>
> Pat
>
> >
>
--
rm -rf / 2>/dev/null - http://null.in
Dont judge those who try and fail, judge those who fail to try..
--~--~---------~--~----~------------~-------~--~----~
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 11/20/06, Pratik <pratiknaik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > remote_function(:update => "options", > :url => { :action => :update_options }, > :with => "''post%5Bperson_id%5D=''+$F(''post_person_id'')") >Hey Pratik, thanx for your anwser, basically, this is what I have: <select id="config_<%= conf.conf_name %>" name="config[<%conf.conf_name %>]" onchange="<% remote_function( :url => { :action => :update , :id=>conf.id,''config[confvalue]''=>''+this[this.selectedIndex].value'' }) %>"><option value="0" selected>No</option><option value="1">Yes</option><option value="0" selected>No</option><option value="3" >Maybe</option></select>the poblem is that the updated value of confvalue is ''this[this.selectedIndex].value'' instead of the selected value. I also tried something like that: :with=>config[confvalue]''=>''+this[this.selectedIndex].value'' but in that case nothing get updated at all. any idea what''s wrong? thanx in advance Pat --~--~---------~--~----~------------~-------~--~----~ 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 11/20/06, Patrick Aljord <patcito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 11/20/06, Pratik <pratiknaik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > remote_function(:update => "options", > > :url => { :action => :update_options }, > > :with => "''post%5Bperson_id%5D=''+$F(''post_person_id'')") > > > > Hey Pratik, thanx for your anwser, > basically, this is what I have: > > <select id="config_<%= conf.conf_name %>" name="config[<%> conf.conf_name %>]" onchange="<%> remote_function( :url => { :action => :update , > :id=>conf.id,''config[confvalue]''=>''+this[this.selectedIndex].value'' }) > %>"><option value="0" selected>No</option><option value="1" > >Yes</option><option value="0" selected>No</option><option value="3" > >Maybe</option></select> > > > the poblem is that the updated value of confvalue is > ''this[this.selectedIndex].value'' instead of the selected value. > I also tried something like that: > > :with=>config[confvalue]''=>''+this[this.selectedIndex].value'' > > > but in that case nothing get updated at all. > any idea what''s wrong? > > thanx in advance > > Pat > > > >Pat, You can also use observe_field(). <%= select :post, :person_id, Person.find(:all).collect {|p| [ p.name, p.id ] } %> <%= observe_field :post_person_id, :url => { ... }, :with => ''post_person_id'' %> Hope this helps, -- Zack Chandler http://depixelate.com http://trackplace.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 -~----------~----~----~----~------~----~------~--~---
Patrick,
Here is a select that will be submitted via AJAX request when changed:
<%= select( :vehicle, :body_type,
@body_types.collect {|bt| [bt, bt]},
{},
:onchange => remote_function( :with =>
"''vehicle[body_type]=''+escape(value)",
:loading =>
"Element.show(''loading-indicator4'')",
:complete =>
evaluate_remote_response,
:url => { :action =>
:vehicle_body_type_select } ) ) %>
This will run the method ''vehicle_body_type_select'' in the
current
controller, and when that action is executed the currently selected
value will be in ''params[:vehicle][:body_type]'' from the :with
parameter. The method passes back Javascript via RJS statements which
are evaluated by the :complete item.
David
Patrick Aljord wrote:> Hey all,
> I have a select("post", "person_id",
Person.find_all.collect {|p|
> [ p.name, p.id ] }) and I would like to submit the value when it is
> selected.
> I know I have to do something like this: onchange="<%>
remote_function(:update => "options",
> :url => { :action => :update_options })
> but how can I pass it the value of the selected option?
>
> thanx in advance
>
> Pat
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---