I have a small form which a user will sit in front of for an hour or so, entering some data from faxes. The form contains several selections which take a while to determine. I want to be able to submit the form via AJAX and not have a refresh which will then need to go and get all the select data again. Yeah, I could cache it, but I''d rather have the form on the screen, the user enters the data and presses "submit" and they''re told "OK" or "something went wrong" sort of thing. If it is OK, then the form is cleared and ready for the next lot of data and the fax is put into 1 pile. If something went wrong it goes into another pile. The code is intranet only. I''m using prototype.js V1.5.1.1 How do I submit a form via AJAX, and NOT have the form refresh? I assume having an <input type="submit"> is my problem ... -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Richard, the magic is the >onSubmit< eventhandler. You use it either in the <form> TAG or define it in as I did in the way I did in the cascadingSelects ( line 87) I sent you some time ago. The magic to prevent the form from submission and casing a full page reload is to return a >false< from the function called by the eventhandler. To collect the data from the form I propose to use the >serialize< method of the Form treatment functionality of prototype. hope that helps Bastian On 7/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > I have a small form which a user will sit in front of for an hour or > so, entering some data from faxes. The form contains several > selections which take a while to determine. > > I want to be able to submit the form via AJAX and not have a refresh > which will then need to go and get all the select data again. Yeah, I > could cache it, but I''d rather have the form on the screen, the user > enters the data and presses "submit" and they''re told "OK" or > "something went wrong" sort of thing. If it is OK, then the form is > cleared and ready for the next lot of data and the fax is put into 1 > pile. If something went wrong it goes into another pile. > > The code is intranet only. > > I''m using prototype.js V1.5.1.1 > > How do I submit a form via AJAX, and NOT have the form refresh? > > I assume having an <input type="submit"> is my problem ... > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > > > >-- -- spread the word ... see www.browsehappy.com ;o) Calvin: Weekends don''t count unless you spend them doing something completely pointless. Join the Greater IBM Connection ( http://www.xing.com/premiumgroup-6291.d26b7d) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
HI, me again .. recently found : http://www.prototypejs.org/api/form/request This is an allin one method to collect and send the form data to you response file. Do not forget to return false afterwards ;o) hf Bastian On 7/23/07, Bastian Feder <bastian.feder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hey Richard, > > the magic is the >onSubmit< eventhandler. > You use it either in the <form> TAG or define it in as I did in the way I > did in the cascadingSelects ( line 87) I sent you some time ago. > > The magic to prevent the form from submission and casing a full page > reload is to return a >false< from the function called by the eventhandler. > To collect the data from the form I propose to use the >serialize< method > of the Form treatment functionality of prototype. > > hope that helps > > Bastian > > On 7/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > I have a small form which a user will sit in front of for an hour or > > so, entering some data from faxes. The form contains several > > selections which take a while to determine. > > > > I want to be able to submit the form via AJAX and not have a refresh > > which will then need to go and get all the select data again. Yeah, I > > could cache it, but I''d rather have the form on the screen, the user > > enters the data and presses "submit" and they''re told "OK" or > > "something went wrong" sort of thing. If it is OK, then the form is > > cleared and ready for the next lot of data and the fax is put into 1 > > pile. If something went wrong it goes into another pile. > > > > The code is intranet only. > > > > I''m using prototype.js V1.5.1.1 > > > > How do I submit a form via AJAX, and NOT have the form refresh? > > > > I assume having an <input type="submit"> is my problem ... > > > > -- > > ----- > > Richard Quadling > > Zend Certified Engineer : > > http://zend.com/zce.php?c=ZEND002498&r=213474731 > > "Standing on the shoulders of some very clever giants!" > > > > > > > > > > > -- > -- > spread the word ... see www.browsehappy.com ;o) > > Calvin: Weekends don''t count unless you spend them doing something > completely pointless. > > Join the Greater IBM Connection ( > http://www.xing.com/premiumgroup-6291.d26b7d)-- -- spread the word ... see www.browsehappy.com ;o) Calvin: Weekends don''t count unless you spend them doing something completely pointless. Join the Greater IBM Connection ( http://www.xing.com/premiumgroup-6291.d26b7d) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 23/07/07, Bastian Feder <bastian.feder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Richard, > > the magic is the >onSubmit< eventhandler. > You use it either in the <form> TAG or define it in as I did in the way I > did in the cascadingSelects ( line 87) I sent you some time ago. > > The magic to prevent the form from submission and casing a full page reload > is to return a >false< from the function called by the eventhandler. > To collect the data from the form I propose to use the >serialize< method of > the Form treatment functionality of prototype. > > hope that helps > > Bastian > > > On 7/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > I have a small form which a user will sit in front of for an hour or > > so, entering some data from faxes. The form contains several > > selections which take a while to determine. > > > > I want to be able to submit the form via AJAX and not have a refresh > > which will then need to go and get all the select data again. Yeah, I > > could cache it, but I''d rather have the form on the screen, the user > > enters the data and presses "submit" and they''re told "OK" or > > "something went wrong" sort of thing. If it is OK, then the form is > > cleared and ready for the next lot of data and the fax is put into 1 > > pile. If something went wrong it goes into another pile. > > > > The code is intranet only. > > > > I''m using prototype.js V1.5.1.1 > > > > How do I submit a form via AJAX, and NOT have the form refresh? > > > > I assume having an <input type="submit"> is my problem ...In reading about event.observe, it doesn''t stop other events, which I assume means the default behaviour of the submit. Event.observe(''fleetForm'', ''submit'', contractSetupSubmit); Even with just function contractSetupSubmit() { return false; } I''m still getting a refresh. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 23/07/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23/07/07, Bastian Feder <bastian.feder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hey Richard, > > > > the magic is the >onSubmit< eventhandler. > > You use it either in the <form> TAG or define it in as I did in the way I > > did in the cascadingSelects ( line 87) I sent you some time ago. > > > > The magic to prevent the form from submission and casing a full page reload > > is to return a >false< from the function called by the eventhandler. > > To collect the data from the form I propose to use the >serialize< method of > > the Form treatment functionality of prototype. > > > > hope that helps > > > > Bastian > > > > > > On 7/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > I have a small form which a user will sit in front of for an hour or > > > so, entering some data from faxes. The form contains several > > > selections which take a while to determine. > > > > > > I want to be able to submit the form via AJAX and not have a refresh > > > which will then need to go and get all the select data again. Yeah, I > > > could cache it, but I''d rather have the form on the screen, the user > > > enters the data and presses "submit" and they''re told "OK" or > > > "something went wrong" sort of thing. If it is OK, then the form is > > > cleared and ready for the next lot of data and the fax is put into 1 > > > pile. If something went wrong it goes into another pile. > > > > > > The code is intranet only. > > > > > > I''m using prototype.js V1.5.1.1 > > > > > > How do I submit a form via AJAX, and NOT have the form refresh? > > > > > > I assume having an <input type="submit"> is my problem ... > > In reading about event.observe, it doesn''t stop other events, which I > assume means the default behaviour of the submit. > > Event.observe(''fleetForm'', ''submit'', contractSetupSubmit); > > Even with just > > function contractSetupSubmit() { return false; } > > I''m still getting a refresh.Ha! $(''fleetForm'').onsubmit = contractSetupSubmit; with return false in contractSetupSubmit() is working. And using the form.request method is all working fine too. Thanks. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, you were faster than I was .;o) I just wanted to wirte you that ;o) hf Bastian On 7/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > On 23/07/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > On 23/07/07, Bastian Feder <bastian.feder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hey Richard, > > > > > > the magic is the >onSubmit< eventhandler. > > > You use it either in the <form> TAG or define it in as I did in the > way I > > > did in the cascadingSelects ( line 87) I sent you some time ago. > > > > > > The magic to prevent the form from submission and casing a full page > reload > > > is to return a >false< from the function called by the eventhandler. > > > To collect the data from the form I propose to use the >serialize< > method of > > > the Form treatment functionality of prototype. > > > > > > hope that helps > > > > > > Bastian > > > > > > > > > On 7/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > > > I have a small form which a user will sit in front of for an hour or > > > > so, entering some data from faxes. The form contains several > > > > selections which take a while to determine. > > > > > > > > I want to be able to submit the form via AJAX and not have a refresh > > > > which will then need to go and get all the select data again. Yeah, > I > > > > could cache it, but I''d rather have the form on the screen, the user > > > > enters the data and presses "submit" and they''re told "OK" or > > > > "something went wrong" sort of thing. If it is OK, then the form is > > > > cleared and ready for the next lot of data and the fax is put into 1 > > > > pile. If something went wrong it goes into another pile. > > > > > > > > The code is intranet only. > > > > > > > > I''m using prototype.js V1.5.1.1 > > > > > > > > How do I submit a form via AJAX, and NOT have the form refresh? > > > > > > > > I assume having an <input type="submit"> is my problem ... > > > > In reading about event.observe, it doesn''t stop other events, which I > > assume means the default behaviour of the submit. > > > > Event.observe(''fleetForm'', ''submit'', contractSetupSubmit); > > > > Even with just > > > > function contractSetupSubmit() { return false; } > > > > I''m still getting a refresh. > > Ha! > > $(''fleetForm'').onsubmit = contractSetupSubmit; > > with return false in contractSetupSubmit() is working. > > And using the form.request method is all working fine too. > > Thanks. > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > > > >-- -- spread the word ... see www.browsehappy.com ;o) Calvin: Weekends don''t count unless you spend them doing something completely pointless. Join the Greater IBM Connection ( http://www.xing.com/premiumgroup-6291.d26b7d) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 23 Jul., 14:47, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23/07/07, Richard Quadling <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > In reading about event.observe, it doesn''t stop other events, which I > > assume means the default behaviour of the submit. > > > Event.observe(''fleetForm'', ''submit'', contractSetupSubmit); > > > Even with just > > > function contractSetupSubmit() { return false; } > > > I''m still getting a refresh. > > Ha! > > $(''fleetForm'').onsubmit = contractSetupSubmit; > > with return false in contractSetupSubmit() is working. > > And using the form.request method is all working fine too. > > Thanks. > --This should also prevent the default behavior (ie. submitting the form): Event.observe(''fleetForm'', ''submit'', Event.stop); or, if you need to do more: function contractSetupSubmit(ev) { Event.stop(ev); /* do your stuff */ } Event.observe(''fleetForm'', ''submit'', contractSetupSubmit); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 23/07/07, Tobias <tobias.michaelsen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 23 Jul., 14:47, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > On 23/07/07, Richard Quadling <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > In reading about event.observe, it doesn''t stop other events, which I > > > assume means the default behaviour of the submit. > > > > > Event.observe(''fleetForm'', ''submit'', contractSetupSubmit); > > > > > Even with just > > > > > function contractSetupSubmit() { return false; } > > > > > I''m still getting a refresh. > > > > Ha! > > > > $(''fleetForm'').onsubmit = contractSetupSubmit; > > > > with return false in contractSetupSubmit() is working. > > > > And using the form.request method is all working fine too. > > > > Thanks. > > -- > > This should also prevent the default behavior (ie. submitting the > form): > > Event.observe(''fleetForm'', ''submit'', Event.stop); > > or, if you need to do more: > > function contractSetupSubmit(ev) { Event.stop(ev); /* do your stuff > */ } > Event.observe(''fleetForm'', ''submit'', contractSetupSubmit);Oh. More prototype-ish goodiness. Thanks. So do I event.observe or element.submit to get contractsetupsubmit as the submit handler? -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---