Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using ENTER key instead of TAB to move on next element

    hi
    i have this code using ENTER key instead of TAB to move on next form element which work fine on the IE but not working Firefox.
    <input type="text" name="givename" onKeyDown="if(event.keyCode==13) event.keyCode=9;" />
    <input type="text" name="surname" onKeyDown="if(event.keyCode==13) event.keyCode=9;" />

    Seaching some page it says: "This is not working in Mozilla because the `event` object is a Microsoft proprietary trick". So what then is the same function on Mozilla?

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    see this example:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script type="text/javascript">
    function 
    tabE(obj,e){
    var 
    e=(typeof event!='undefined')?window.event:e;// IE : Moz
    if(e.keyCode==13){
    var 
    ele document.forms[0].elements;
    for(var 
    i=0;i<ele.length;i++){
    var 
    q=(i==ele.length-1)?0:i+1;// if last element : if any other
    if(obj==ele[i]){ele[q].focus();break}
    }
    return 
    false;
    }
    }
    </script>
    </head>
    <body>
    <form>
    <input name="" type="text" onkeypress="return tabE(this,event)">
    <input name="" type="text" onkeypress="return tabE(this,event)">
    <input name="" type="text" onkeypress="return tabE(this,event)">
    </form>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •