struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barnett, Brian W." <bbarn...@scholarinc.com>
Subject RE: [OT] "Enter" key listener for form submittal
Date Wed, 01 Sep 2004 15:40:50 GMT
I had a problem where I wanted to use images as the buttons on forms, but
then I lost the "enter" key and "spacebar" functionality. I ended up doing
this to solve it.

<input type="image"
onclick="document.agentForm.action='/do/agent?Dispatch=Save';
document.agentForm.submit();" src="/images/btn_reg_save_def.gif" border="0"
alt="Save agent" onmouseover="src='/images/btn_reg_save_roll.gif'"
onmouseout="src='/images/btn_reg_save_def.gif'"/>

I use the syntax above for the "default" button on the form and leave the
other buttons <a href...><img...></a>

Don't know if something like this would work in your situation though. It
works in IE and Netscape.

-----Original Message-----
From: Erik Weber [mailto:erikweber@mindspring.com] 
Sent: Wednesday, September 01, 2004 9:34 AM
To: Struts Users Mailing List
Subject: Re: [OT] "Enter" key listener for form submittal

It is necessary in my case because it is a requirement specified by the 
client. On very simple forms, it often won't require any programming. 
But if you have multiple submit buttons, it becomes a problem.

Erik


Barnett, Brian W. wrote:

>Out of curiosity, why is an enter key listener necessary in order to submit
>a form?
>
>-----Original Message-----
>From: Erik Weber [mailto:erikweber@mindspring.com] 
>Sent: Wednesday, September 01, 2004 9:18 AM
>To: Struts Users Mailing List
>Subject: Re: [OT] "Enter" key listener for form submittal
>
>
>
>David Durham wrote:
>
>  
>
>>Erik Weber wrote:
>>
>>    
>>
>>>I found this JavaScript, which is supposed to listen for the "Enter" key
>>>on any browser (and submit the form on keypress). However, it doesn't
>>>seem to be working in IE:
>>>
>>><script language="JavaScript">
>>>if (document.layers) document.captureEvents(Event.KEYDOWN);
>>>document.onkeydown =
>>>function (evt) {
>>>var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : evt.keyCode;
>>>if (keyCode == 13) {
>>>document.forms[0].submit();
>>>}
>>>}
>>></script>
>>>
>>>
>>>Does anyone have an "Enter" key listener that has been shown to work in
>>>all browsers, or know what is wrong with this one?
>>>      
>>>
>>Consider returning false in order to halt the normal event 
>>propagation.  It may be that you are triggering the right form, but 
>>the "enter" event is being passed on and submitting the cancel button.
>>    
>>
>
>
>Thanks, I will try that.
>
>  
>
>>Also, does document.forms[0].submit() trigger the submit with a submit 
>>value of cancel?  Does that make since?
>>    
>>
>
>
>Hmm, would it not fail also on Mozilla if that were true?
>
>Thanks,
>Erik
>
>
>  
>
>>- Dave
>>
>>
>>
>>
>>
>>    
>>
>>>Thanks,
>>>Erik
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>> 
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message