cursor appearing in a form
Hi!
I have a link which opens up a new page with a form. When I click on the link, I'd like the flashing cursor to already be in the first field of the form, but I have to click there myself to start typing. Is there any way to get it there automatically without having to click in the field. Please help. Thanks!
Rams
Arielladog posted this at 02:39 — 4th May 2000.
They have: 122 posts
Joined: Jun 1999
You justhave to tell the page to focus on the input box. Here is what I mean..you would stick it into the body tag like this:
<body onload="document.formName.inputAreaName.focus()" In this example, replace the bold and italicized items to fit your document. Here is an example document of what I mean.
<html>
<head>
</head>
<body onload="document.info.name.focus()">
<form name="info">
What is your name?
<input type="text" name="name" value="">
</form>
</body>
</html>
P.S.-you can crash someone's browser by using some of this...try
<html>
<head>
</head>
<body onload="document.info.name.focus()">
<form name="info">
What is your name?
<input type="text" name="name" value="" onfocus="this.blur()" onblur="this.focus()">
</form>
</body>
</html>
and your browser crashes...I hope you see why (just thought it was neat and thought I would share)
Moderate at JavaScriptCity Forums
rams posted this at 22:04 — 8th May 2000.
They have: 12 posts
Joined: Sep 1999
Thanks, that worked. But I now have another problem. I have a reset button on the form, and whenever it's pressed, the cursor doesn't appear on form. Is there anyway I can get it to appear after hitting the reset button.
Arielladog posted this at 22:47 — 8th May 2000.
They have: 122 posts
Joined: Jun 1999
try adding this to your reset button:
onclick="document.formName.inputAreaName.focus()" you might have to do it on settime out, I am not sure, but try this first. If this doesn't work, just poast a message saying it doesn't.
Moderate at JavaScriptCity Forums
rams posted this at 23:38 — 8th May 2000.
They have: 12 posts
Joined: Sep 1999
It worked!! Thanks!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.