I found the heart of this code here .  It enables the enter key to act like the tab key until the form needs to be submitted.  I used it to enable hitting enter to submit my forms in Netscape.

<script type="text/javascript">
<!-- Begin
nextfield = "UserID"; // name of first box on page
netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");

function keyDown(DnEvents) { // handles keypress
// determines whether Netscape or Internet Explorer
k = (netscape) ? DnEvents.which : window.event.keyCode;
if (k == 13) { // enter key pressed
if (nextfield == 'done')
 {document.thisform.submit();
 return true; // submit, we finished all fields
}else { // we're not done yet, send focus to next box
eval('document.thisform.' + nextfield + '.focus()');
return false;
      }
   }
}
document. // work together to analyze keystrokes
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);
//  End -->
</script>

Then you mark the input tags like this:

<input type="text" name="UserID" size="20" tabindex="1"
    onfocus="document.thisform.UserID.select();nextfield='Password';">

<input type="password" name="Password" size="20" tabindex="2"
    onfocus="document.thisform.Password.select();nextfield='done';">

I hope this helps.  It has worked for me in my applications.
 

Billy Cravens wrote:

This will not work.  This is one of those areas where you working against
browser capabilities, not HTML specs, so there's no magic answer.  If it's
not submitting on Enter, you could try playing with some event handlers in
each of your form elements; however, with events such as onKeyPress, there's
little or no chance of making it work in both browsers.

---
Billy Cravens

----- Original Message -----
From: "Alford, Gary" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, July 06, 2001 11:04 AM
Subject: RE: How to trigger an action page by pressing 'Enter' button

> Try changing "<input type=image..." to "<type=submit..." while maintaining
> the image as the source.
>
> ============================================
> Gary L. Alford
> Supplier Product Assurance
> Bell Helicopter Textron
> Phone: (817) 280-6233
> Fax: (817) 278-6233
> mailto:[EMAIL PROTECTED]
> ============================================
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 06, 2001 10:58 AM
> To: [EMAIL PROTECTED]
> Subject: How to trigger an action page by pressing 'Enter' button
>
>
> Hi,
>
> I have an image input button. When it is clicked my action page is
> executed. How to link it with 'Enter' key on a keyboard. Below is my code:
>
>
> <cfform action="updtcontactrecords.cfm" method="post">
>
>     <table width="260" border="0" cellspacing="0" cellpadding="0" align
> ="center">
>       <tr>
> ............
>
> ............
> <td>
> <div><input type="image" class="small" src="go_button.png"  name
> ="go_button" border="0" usemap="#go_buttonMap#" alt="submit">
> </div>
>
>           </td>
>      </tr>
>     </table>
>      </cfform>
>      </body>
>      </html>
>
> Henry
>
>
> -------------------------------------------------------------------------
> This email server is running an evaluation copy of the MailShield anti-
> spam software. Please contact your email administrator if you have any
> questions about this message. MailShield product info: www.mailshield.com
>
> -----------------------------------------------
> To post, send email to [EMAIL PROTECTED]
> To subscribe / unsubscribe: http://www.dfwcfug.org
>
> -------------------------------------------------------------------------
> This email server is running an evaluation copy of the MailShield anti-
> spam software. Please contact your email administrator if you have any
> questions about this message. MailShield product info: www.mailshield.com
>
> -----------------------------------------------
> To post, send email to [EMAIL PROTECTED]
> To subscribe / unsubscribe: http://www.dfwcfug.org
>

-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

begin:vcard 
n:Gillham;Bob
tel;fax:(903) 534-2250
tel;work:(903) 534-2174
x-mozilla-html:FALSE
org:Brookshire Grocery Co.;Information Technology
adr:;;PO Box 1411;Tyler;TX;75710;
version:2.1
email;internet:[EMAIL PROTECTED]
title:Programmer Analyst II
fn:Bob Gillham
end:vcard

Reply via email to