Hello, I want to ask the users specific question using javascript, and then get the answer :) <%= button_to_function "My Test", "prompt(''Your name is?'')" %> How can I accomplish this? I hope someone out there can help me with this, and thanks for your help :D -- 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 10/11/07, Jamal Soueidan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello, > > I want to ask the users specific question using javascript, and then get > the answer :) > > <%= button_to_function "My Test", "prompt(''Your name is?'')" %> > > How can I accomplish this?Well, that will do it. What do you want to do with the answer? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bob Showalter wrote:> On 10/11/07, Jamal Soueidan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> Hello, >> >> I want to ask the users specific question using javascript, and then get >> the answer :) >> >> <%= button_to_function "My Test", "prompt(''Your name is?'')" %> >> >> How can I accomplish this? > > Well, that will do it. What do you want to do with the answer?I need to catch the answer and add it to the database :D -- 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 10/12/07, Jamal Soueidan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Bob Showalter wrote: > > On 10/11/07, Jamal Soueidan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> > >> Hello, > >> > >> I want to ask the users specific question using javascript, and then get > >> the answer :) > >> > >> <%= button_to_function "My Test", "prompt(''Your name is?'')" %> > >> > >> How can I accomplish this? > > > > Well, that will do it. What do you want to do with the answer? > > I need to catch the answer and add it to the database :DI suggest you put the results of prompt() into a (js) variable and then pass it to the server through an Ajax.Request. You can use the Rails remote_function() helper to write the js for that. Use the :with option to pass the js variable. Here''s an example from an app of mine: <%= javascript_tag %Q{ function x_add_task() { var name = prompt(''Name for new task'', ''''); if (name == null) return; #{remote_function :url => {:action => ''x_add_task'', :id => @obj.id}, :with => "''name='' + name" } } } %> Then later: <%= link_to_function ''Add Task'', ''x_add_task()'' %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you very much Bob Showalter :) -- 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 -~----------~----~----~----~------~----~------~--~---