Hi all I want to translate this HTML code into a RoR code. The form is very simple, it has a combo box, and when the user selects a value in the list I would like to display a message that says, "You selected the color X" I know that I need a controller and a viewer. My question is about what do I need to code the viewer to do somethin similar to this: <body> <form name="form1" method="post" action=""><label>Select A Color From The List:</label> <select name="select"> <option value="Red">Red</option> <option value="Green">Green</option> <option value="Blue">Blue</option> <option value="Pink">Pink</option> <option value="Yellow">Yellow</option> </select> </form> </body> 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 -~----------~----~----~----~------~----~------~--~---
On 10/11/06, Jose Pepe <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I want to translate this HTML code into a RoR code. The form is very > simple, it has a combo box, and when the user selects a value in the > list I would like to display a message that says, "You selected the > color X" > > <body> > <form name="form1" method="post" action=""><label>Select A Color From > The List:</label> > <select name="select"> > <option value="Red">Red</option> > <option value="Green">Green</option> > <option value="Blue">Blue</option> > <option value="Pink">Pink</option> > <option value="Yellow">Yellow</option> > </select> > </form> > </body>You can do something like this: <select name="select" onchange="alert(''You selected the color ''+$F(this));"> ... If you want to run some action on change, then write like this: <select name=''select'' onchange=''<%= remote_function :url => { :action => ''changed'' }, :with => "Form.Element.serialize(this)" %>''> .... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Maxim, here is what I wrote in ROR and it works html> <head> <title> Combo Box!!!</title> </head> <body> <%= start_form_tag :controller=>''color'', :action=>''hi'' %> <p>Select a color: <%=select_tag "textTag", options_for_select(%w{ Red Green Blue Pink Yelow }) %> </p><p> <label><%= @message %></label> </p> <p> <%= submit_tag( "Submit") %> </p> <%= end_form_tag %> </body> </html> thanks Kulkin wrote:> On 10/11/06, Jose Pepe <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> <option value="Red">Red</option> >> <option value="Green">Green</option> >> <option value="Blue">Blue</option> >> <option value="Pink">Pink</option> >> <option value="Yellow">Yellow</option> >> </select> >> </form> >> </body> > > > You can do something like this: > <select name="select" onchange="alert(''You selected the color > ''+$F(this));"> > ... > > If you want to run some action on change, then write like this: > <select name=''select'' onchange=''<%= remote_function :url => { :action => > ''changed'' }, :with => "Form.Element.serialize(this)" %>''> > ....-- 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 -~----------~----~----~----~------~----~------~--~---