Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member mikeycorn's Avatar
    Join Date
    Mar 2003
    Posts
    272
    Member #
    891
    I have a simple contact form with two text boxes and a textarea, but on landing on the page, the cursor is not flashing in the first box the way I'd like it to.

    How do I make that first text box the default with a flashing cursor when the visitor lands on the page? I've tried tabindex with strange results.
    ~ mikeycorn
    With over 72,000 questions worth of user submitted quizzes, it's the world's most popular quiz creation software:
    PEST - The Personal Exam Self-Tester

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    HTML cannot do that but JavaScript can.

    The below code shows you how.

    HTML Code:
    <html>
    
    <head>
    
    <script type="text/javascript">
    
    function setFocusToField()
       {
    	document.example.field1.focus();
       }
    
    </script>
    
    </head>
    
    <body onload="setFocusToField();">
    
    <form name="example" action="file.php" method="post">
    
    	<p>Field 1: <input type="text" name="field1" /></p>
    
    	<p>Field 2: <input type="text" name="field2" /></p>
    
    	<p>Field 3: <textarea name="field3" rows="6" cols="50"></textarea></p>
    
    	<p><input type="submit" name="submit" value="Do something or other..." /></p>
    
    </form>
    
    </body>
    </html>

  4. #3
    Senior Member mikeycorn's Avatar
    Join Date
    Mar 2003
    Posts
    272
    Member #
    891
    Beautiful! Thanks!
    ~ mikeycorn
    With over 72,000 questions worth of user submitted quizzes, it's the world's most popular quiz creation software:
    PEST - The Personal Exam Self-Tester

  5. #4
    Junior Member sushil's Avatar
    Join Date
    Jan 2008
    Posts
    21
    Member #
    16339
    Yeah ! it's really helpful.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:05 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com