" <%= javascript_include_tag :defaults %> </head> <body> <% form_tag ''/chap_two/index'' do %> <div> <%= text_field_tag :address1, params[:address1] %> <%= text_field_tag :address2, params[:address2] %> <%= submit_tag ''Save'' %> </div> <% end -%> " I''m trying to execute a javascript function when i click the "save" button... can anyone tell me how... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try with <%= submit_tag ''Save'', :onclick => "javascript_method();" %> -- 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 9 Apr 2008, at 09:06, Adi wrote:> > " > <%= javascript_include_tag :defaults %> > > </head> > <body> > > <% form_tag ''/chap_two/index'' do %> > <div> > <%= text_field_tag :address1, params[:address1] %> > <%= text_field_tag :address2, params[:address2] %> > <%= submit_tag ''Save'' %> > </div> > <% end -%>> I''m trying to execute a javascript function when i click the "save" > button...You could stick an onclick on the submit button. However, I suspect that you actually want an onsubmit on the form, ie form_tag(''chap_two/ index'', :onsubmit => ''...''). This will trigger if the user submits the form by hitting the enter key, whereas an onclick on the submit button obviously wouldn''t Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
form_tag(''chap_two/index'', :onsubmit => ''...'') would be better. -- 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 -~----------~----~----~----~------~----~------~--~---
at last... it "half" works... i can call the function and it shows an alert but the second command is not working... i assume it because the gdir is not loaded... function setDirections(fromAddress, toAddress, locale) { alert("a"); gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale }); } is there anything i can do with this...??? Thanks, Adi --~--~---------~--~----~------------~-------~--~----~ 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 9 Apr 2008, at 10:10, Adi wrote:> > at last... it "half" works... i can call the function and it shows an > alert but the second command is not working... i assume it because the > gdir is not loaded... > > function setDirections(fromAddress, toAddress, locale) { > alert("a"); > gdir.load("from: " + fromAddress + " to: " + toAddress, > { "locale": locale }); > } >I don''t have the faintest clue what gdir is, however if you''re not already using firebug to debug your javascript code, now is the time to start Fred> is there anything i can do with this...??? > > Thanks, > > > Adi > >--~--~---------~--~----~------------~-------~--~----~ 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 9 Apr 2008, at 10:26, Adi wrote:> well, it''s a container that contains kinda google map... it will show > the driving direction (best one from google''s version) from one > address to another address... > > about the debugger, well honestly i don''t even know it...If you don''t, then it''s time to learn. Install the firebug extension for firefox and you''ll have a pretty handy javascript debugger (and dom inspector, css viewer etc...) Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Great, it works... i''ve put these code below " <% form_tag "/chap_two/find", :onsubmit => "setDirections(''san fransisco'', ''new york'',''en_US'')" do -%> <%= text_field_tag :address1, params[:address1] %> <%= text_field_tag :address2, params[:address2] %> <div><%= submit_tag ''Show'' %></div> <% end -%> " but what if i want to use my params[:address1] and params[:address2] instead of ''san fransisco'' and ''new york''... i''ve tried these code below but it''s not working... " <% form_tag "/chap_two/find", :onsubmit => "setDirections("&<% params[:address1] %> & ", " & <% params[:address1] %> & ",''en_US'')" do -%> <%= text_field_tag :address1, params[:address1] %> <%= text_field_tag :address2, params[:address2] %> <div><%= submit_tag ''Show'' %></div> <% end -%> " --~--~---------~--~----~------------~-------~--~----~ 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 have this function below inside my public/application.js and i''m wondering whether i can replace "San Fransisco" and "New York" in this command "setDirections("San Francisco", "New York", "en_US");" with session[:address1] and session[:address2]....??? Please can anyone show me how to do it... " function initialize() { if (GBrowserIsCompatible()) { alert("kyaaaaaaaa") map = new GMap2(document.getElementById("map_canvas")); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "load", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); setDirections("San Francisco", "New York", "en_US"); } } " " --~--~---------~--~----~------------~-------~--~----~ 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 Apr 2008, at 03:41, Adi wrote:> > Great, it works... > i''ve put these code below > " > <% form_tag "/chap_two/find", :onsubmit => "setDirections(''san > fransisco'', ''new york'',''en_US'')" do -%> > <%= text_field_tag :address1, params[:address1] %> > <%= text_field_tag :address2, params[:address2] %> > <div><%= submit_tag ''Show'' %></div> > <% end -%> > " > but what if i want to use my params[:address1] and params[:address2] > instead of ''san fransisco'' and ''new york''... > i''ve tried these code below but it''s not working...setDirections($F(''address1''), $F(''address2''), ''en_US'') should do the trick, assuming that those text fields have their id set to address1 and address2. Also (unless you want the form submitted as well as your js called) you probably want a return false; at the end of your onsubmit. Fred> > > " > <% form_tag "/chap_two/find", :onsubmit => "setDirections("&<% > params[:address1] %> & ", " & <% params[:address1] %> & ",''en_US'')" do > -%> > <%= text_field_tag :address1, params[:address1] %> > <%= text_field_tag :address2, params[:address2] %> > <div><%= submit_tag ''Show'' %></div> > <% end -%> > " > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---