I have a page that contains a form and some input fields. instead of a submit button to post the data back to the server I want to put a link. This link when clicked should post the data back to the server. Any pointers on how to do this? I have put a link, but it doesn''t post back the data from input elements, i also set :post => true in link_to URL helper but its not working. Please help -- 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 -~----------~----~----~----~------~----~------~--~---
Dipesh Batheja wrote:> I have a page that contains a form and some input fields. instead of a > submit button to post the data back to the server I want to put a link. > This link when clicked should post the data back to the server. Any > pointers on how to do this? I have put a link, but it doesn''t post back > the data from input elements, i also set :post => true in link_to URL > helper but its not working. Please helpI think you still want to submit the form using a post, but you want a link to do it instead of a button? In that case, you should still be using a form tag set up with the correct action and parameters. Then create a link to submit the form. But we''ll use JavaScript to submit it, so we can''t really use link_to. We''ll use link_to_function instead. link_to_function "Link Text", "document.forms[0].submit();" This will submit the first form on the document (the page). If you have more than one form on the page, you''ll have to specify which one. -- 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 Oct 13, 2006, at 18:32, Dipesh Batheja wrote:> I have a page that contains a form and some input fields. instead > of a submit button to post the data back to the server I want to > put a link. > This link when clicked should post the data back to the server. Any > pointers on how to do this?You need to create a link that executes some javascript which submits the form when clicked. $(''id_of_form'').submit() or something to that effect is the Javascript you want. -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Kian Wright wrote:> I think you still want to submit the form using a post, but you want a > link to do it instead of a button? > > In that case, you should still be using a form tag set up with the > correct action and parameters. Then create a link to submit the form. > But we''ll use JavaScript to submit it, so we can''t really use link_to. > We''ll use link_to_function instead. > > link_to_function "Link Text", "document.forms[0].submit();" > > This will submit the first form on the document (the page). If you have > more than one form on the page, you''ll have to specify which one.I tried to do this too (taking your suggestion above), but when I make a change on the form and click my "Save" link_to_function, I get an endless "Loading..." and have to restart the server to move anywhere. What did I do wrong? I tried it with and without a semi-colon. I only have one form on the page, the one that Rails creates from the start_form_tag, which happens to be lower on the page that the "Save" link (but the position shouldn''t matter, right?). Shauna -- 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 -~----------~----~----~----~------~----~------~--~---
Shauna wrote:> I tried to do this too (taking your suggestion above), but when I make a > change on the form and click my "Save" link_to_function, I get an > endless "Loading..." and have to restart the server to move anywhere. > What did I do wrong? I tried it with and without a semi-colon. I only > have one form on the page, the one that Rails creates from the > start_form_tag, which happens to be lower on the page that the "Save" > link (but the position shouldn''t matter, right?). > > ShaunaCheck again the form I tried link_to_function "Link Text", "document.forms[0].submit();" too and my start_form_tag working properly -- 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 -~----------~----~----~----~------~----~------~--~---