SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    set focus dont work in IE but works in FF whats the problem?

    can anyone please help me?i don't know why this script don't work in IE its working fine FF.here's my code

    Code:
    <body onLoad="document.myForm.getElementById(StudNo.focus());">
      <form method="POST" action="validate.php" name="myForm">
      <br><br><br><br>
      <table border="1" align="center" cellspacing="3" cellpadding="5" bordercolor="#DAA520">
      <tr>
      <td bgcolor="#90EE90">
    <table border="0" cellpadding="1" cellspacing="1" align="center" width="400">
      <tr>
        <td align="center">Log In to Survey</td>
      </tr>
      <tr>
        <td align="center">Student Number:
        <input type="text" name="StudNo" id="StudNo" size="30"></td>
      </tr>
      <tr>
        <td align="center"><input type="submit" value="Log In"></td>
      </tr>
      <tr>
        <td align="center"><i>Don't have an account?</i> <a href="register.php">Click here</td>
      </tr>
    </table>
    </td>
      </tr>
      </table>
    </form>

    the IE results in an error that says StudNo is undefined, i don't why it is i declared it as an ID and its name so why? tnx in advance for anyone who can help me.

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let's try using unobtrusive javascript:

    Put this just above the end body tag (</body>):

    Code JavaScript:
    <script type="text/javascript">
    document.getElementById("StudNo").focus();
    </script>

    That's all you need...
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)


Bookmarks

Posting Permissions

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