www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 07-06-2006, 12:57 PM
    fh63 fh63 is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 1
    Problem with "focus()"

    Hi,
    Instead of putting the focus on the first field, I get the focus on the second field!!!!
    Here my code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript">

    function tab(obj) {
    // alert("test");

    var lettre1= event.keyCode;
    if (lettre1 == 9) {

    obj.form.elements[0].focus();
    alert ("valeur="+obj.form.elements[0].value);

    }

    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Document sans nom</title>
    </head>
    <body>
    <form name="formulaire" action="">
    <input type="text" name="champ1" id="champ1" maxlength="6"/>
    <input type="text" name="champ2" id="champ2" maxlength="6"/>
    <input type="text" name="champ3" id="champ3" maxlength="6"/>
    <input type="text" name="champ4" id="champ4" maxlength="6" onkeyDown="tab(this);"/>
    <input type="hidden" name="champ5" id="champ5" maxlength="6"/>
    </form>
    </body>
    </html>

    Do you have any suggestion?
    Thanks
    Fh
    Reply With Quote
      #2  
    Old 07-08-2006, 02:14 PM
    phpnovice phpnovice is offline
    Banned
     
    Join Date: Dec 2004
    Posts: 8,652
    That is because you programmatically moved the focus to the first field and then the browser responded to the tab key and moved the focus to the next field.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:00 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.