This isn''t really on topic for prototype (although solutions using prototype are welcome), but is more of an HTML/JS question about forms. If you have a form with an input of type ''submit'', then while you''re entering info in that form and you press ''Enter'', the form will submit. But if all you have are inputs of type ''button'' this doesn''t happen. Is there any way to trap that ''Enter'' event (without having to try and trap key press events and fake browser behaviour) or have it apply to a specific ''button'' instead? Thanks. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I believe this only happens as you describe in IE, Firefox (and probably all other browsers) still submits the form when you hit ''enter''. I''m sure there''s a workaround for it, as long as it doesn''t involve listening for keypress events when a form element has focus ;) -justin On 3/28/07, Michael Peters <mpeters-aUYv5hkjw45l57MIdRCFDg@public.gmane.org> wrote:> > This isn''t really on topic for prototype (although solutions using prototype are > welcome), but is more of an HTML/JS question about forms. > > If you have a form with an input of type ''submit'', then while you''re entering > info in that form and you press ''Enter'', the form will submit. But if all you > have are inputs of type ''button'' this doesn''t happen. Is there any way to trap > that ''Enter'' event (without having to try and trap key press events and fake > browser behaviour) or have it apply to a specific ''button'' instead? > > Thanks. > > -- > Michael Peters > Developer > Plus Three, LP > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Peters schrieb:> have are inputs of type ''button'' this doesn''t happen. Is there any way to trap > that ''Enter'' event (without having to try and trap key press events and fakeYou can use <button type=submit">test</button> or is this a misunderstanding on my side now? Frank -- "Laut einer Studie der deutschen Ärztevereinigung sterben immer mehr Rentner vor dem Computer. Sie drücken versehentlich die Tastenkombination Alt+Entfernen." http://www.landseer-stuttgart.de http://www.pn-cms.de --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frank Schummertz <frank.schummertz-wuHXZRSNxgaBAmxm6OvjtTjhTm2NLCe8@public.gmane.org> wrote:> Michael Peters wrote: >> have are inputs of type ''button'' this doesn''t happen. Is there any >> way to trap that ''Enter'' event (without having to try and trap key >> press events and fake > > You can use <button type=submit">test</button> or is this a > misunderstanding on my side now?or, an <input type="image" src="transparent-1pixel.gif" /> the "image input" is functionally equivalent to <input type="submit"> in that it acts as a submit button and also gets activated when the enter key is pressed. Although it''s a bit hackish to use an invisible image for a submit button, these image-inputs work in all browsers -- they''re not IE specific. I have resorted to using them to enable users filling out long forms to just press enter to submit it. hth, -dave --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Useful trick Better than a keypress handler! On 3/29/07, David Kaufman <david-8ZdJMhgJluNWk0Htik3J/w@public.gmane.org> wrote:> > > Frank Schummertz <frank.schummertz-wuHXZRSNxgaBAmxm6OvjtTjhTm2NLCe8@public.gmane.org> wrote: > > Michael Peters wrote: > >> have are inputs of type ''button'' this doesn''t happen. Is there any > >> way to trap that ''Enter'' event (without having to try and trap key > >> press events and fake > > > > You can use <button type=submit">test</button> or is this a > > misunderstanding on my side now? > > or, an <input type="image" src="transparent-1pixel.gif" /> > > the "image input" is functionally equivalent to <input type="submit"> in > that it acts as a submit button and also gets activated when the enter key > is pressed. > > Although it''s a bit hackish to use an invisible image for a submit button, > these image-inputs work in all browsers -- they''re not IE specific. I have > resorted to using them to enable users filling out long forms to just press > enter to submit it. > > hth, > > -dave > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Mar 30, 7:06 am, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Useful trick > Better than a keypress handler!But lousy for accessibility. Many users will find a form with no submit button confusing. Why not just put a visible submit button on the form? Give it a visual label of "Go", "Search", "Send", "Logon" or whatever action will be carried out, but put something there so that users know what will happen when they submit the form. Give users a choice of whether they submit the form by pressing enter or by clicking a button - I prefer to use an enter key, but many users prefer to use mouse clicks. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RobG wrote:> On Mar 30, 7:06 am, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Useful trick >> Better than a keypress handler! > > But lousy for accessibility. > > Many users will find a form with no submit button confusing. Why not > just put a visible submit button on the form? Give it a visual label > of "Go", "Search", "Send", "Logon" or whatever action will be carried > out, but put something there so that users know what will happen when > they submit the form.I think you missed something that I said along the way. The forms I was talking about have <input type="button"> controls. So to the user it looks like there are submit buttons. Just multiple buttons. These buttons are observed with onclick handlers. The problem that I wanted to avoid was having one submit button mixed in with the inputs because submits are treated differently than inputs by browsers (wrt to whether or not they submit the form or not). It was simpler to make them all inputs and not worry about it. But in that case we lost the ''enter'' submission thingy.> Give users a choice of whether they submit the form by pressing enter > or by clicking a button - I prefer to use an enter key, but many users > prefer to use mouse clicks.That''s what I was trying to do, but at the same time make it easy for my form designers so they wouldn''t have to do one thing for submit inputs and another for button inputs. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---