How do I target a form text box when my page loads so the cursor is there at the start?
I have a page that has a username and password login, and I would like to have it so when the page loads the username text area is highlighted and the user can start typing text there right away without having to click in it. How is that accomplished?
Status:
Open Sep 05, 2006 - 10:41 AM
web development, Text Areas, target
3answers
Answers
Sep 05, 2006 - 07:17 PM
In your section add the script
!
where "txtName" is the value in the name attribute of your text box.
and in your tag add
Hope this helps!
Cheers
Peter
Sep 08, 2006 - 07:51 AM
I imagine that you either have a cms or a complex page, so an easier trick is to append a javascript to the very bottom of the page, something like this:
You will need to replace the text 'username' with the actual name of the your username input.
!
For a very simple working example, just save this below as a html file and load it in your local browser. Notice the location of the script after the body close and before the close of the html tag.
!
Oct 04, 2006 - 11:07 AM
Thanks guys, huge help.
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment