I''m trying to have a select form where users select a state, and once
they do that, another select list appears with all the colleges in that
state.
I got it to work using a form_remote_tag, but that required the user to
select their state, then hit a submit button. Is there a good way to do
this using something like :onchange?
Here is the beginning of my first select:
<select name="state" onChange="<%= remote_function(:update
=>
''colleges'',
:url => { :action =>
''get_schools''
}) %>">
The problem is, I''m checking in "get_schools" and the state
is not
getting passed in. How do I pass it in?
--
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
-~----------~----~----~----~------~----~------~--~---
Joe Peck wrote:> I''m trying to have a select form where users select a state, and once > they do that, another select list appears with all the colleges in that > state. > > I got it to work using a form_remote_tag, but that required the user to > select their state, then hit a submit button. Is there a good way to do > this using something like :onchange? > > Here is the beginning of my first select: > > <select name="state" onChange="<%= remote_function(:update => > ''colleges'', > :url => { :action => ''get_schools'' > }) %>"> > > The problem is, I''m checking in "get_schools" and the state is not > getting passed in. How do I pass it in?Still having some problems with this. Can''t seem to pass the value of the select form into the "get_schools" function. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Joe, I''d recommend you pick up Cody Fauser''s RJS tutorial at O''Reilly. I''ll put you on the right track. The way you''re mixing Rails/Ruby with HTML/JS, Rails can''t tell what to do with the pieces you''re giving it. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks, I figured it out a couple days ago though :)
Even added a little highlight feature.
<select id = "what_state" name="state"
onChange="<%= remote_function(
:update => ''colleges'',
:url => { :action =>
''get_schools''},
:with =>
"''state=''+value",
:complete => "new
Effect.Highlight(''college'',{duration: 2.0,
startcolor:
''#00FFCC'',
endcolor:
''#333333'',
restorecolor:
''#333333''})" ) %>">
--
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
-~----------~----~----~----~------~----~------~--~---
Joe Peck wrote:> I''m trying to have a select form where users select a state, and once > they do that, another select list appears with all the colleges in that > state. >Hi Joe: Use observe_field for changes to the select to render a new select via a partial. see the RDoc - http://api.rubyonrails.com/ for Prototype Helpers and this article - http://www.roryhansen.ca/?p=9 Cheers, divotdave -- 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 -~----------~----~----~----~------~----~------~--~---