Closed Thread Icon

Preserved Topic: Set foccus on textbox.. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18500" title="Pages that link to Preserved Topic: Set foccus on textbox.. (Page 1 of 1)" rel="nofollow" >Preserved Topic: Set foccus on textbox.. <span class="small">(Page 1 of 1)</span>\

 
flyer
Bipolar (III) Inmate

From: Helsingborg, Sweden
Insane since: Oct 2000

posted posted 03-05-2002 16:31

I have made a webpage with a textbox but I need focus to be set on the
textbox imediatly and automatically when the page is loaded without the
need to manually click in the texbox to set the marker there...

Is there a javascript or html-tag that fixes this??

JKMabry
Maniac (V) Inmate

From: out of a sleepy funk
Insane since: Aug 2000

posted posted 03-05-2002 17:58

<body onLoad="self.focus();document.formname.fieldname.focus()">

<form name="formname">

<input type="text" name="fieldname">

Jason

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-05-2002 20:42

Beware: if there are multiple text boxes on the page, and the user has a slow modem and they start typing before the page has fully loaded, and they're on another text box when the page finishes loading, their text will suddenly start appearing in the first text box, and it will make them mad. Try this to avoid that issue:

<body onLoad="if(document.formname.fieldname.value=='') {self.focus();document.formname.fieldname.focus();}">

JKMabry
Maniac (V) Inmate

From: out of a sleepy funk
Insane since: Aug 2000

posted posted 03-05-2002 21:11

you're such a stud Slime, where you come up with all this tuff?! Thanks =)

Jason

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 03-06-2002 00:50

I think he has a workshop full of little Slimies working 'round the clock on spiffy tips like that

reitsma
Maniac (V) Mad Scientist

From: the bigger bedroom
Insane since: Oct 2000

posted posted 03-06-2002 00:55

heh - for a more generic version to plug in anywhere, you can try:
document.forms[0].elements[0].focus
or something similar.
it simply focuses on the first element in the first form, which is what you're generally after (unless you have a whole heap of hidden inputs, then things may go a little funny.)

- - r e i t s m a - -
(tifkab)

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-06-2002 01:54

Yeah, but they keep fooling around and avoiding their work...




... see?

JKMabry
Maniac (V) Inmate

From: out of a sleepy funk
Insane since: Aug 2000

posted posted 03-06-2002 02:24

hmmmm

apparently they use their grey matter only when actively engaged in your service. Every dang one has hit the wall, so far.

Jason

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 03-06-2002 07:10

the little buggers

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-06-2002 07:15

Watch it for long enough, JK, and one of them won't hit it. Just keep watching for 20 minutes or so, and don't blink, and you'll see it. Really!

« BackwardsOnwards »

Show Forum Drop Down Menu