Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Cursor start in username-field

Posted 04 Dec 2004 16:42:55
1
has voted
04 Dec 2004 16:42:55 Christian Sen posted:
I know I have asked this question before and had it answered, but I can't seem to find the question in the forum...

Anyway, here goes:

How do I set the cursor to blink in the username-field when opening the loginpage?


Ragards, Sarre

Replies

Replied 04 Dec 2004 18:52:22
04 Dec 2004 18:52:22 Simon Martin replied:
Set focus on the element onLoad

Live the life you love
Love the life you live

Simon

[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 05 Dec 2004 02:04:07
05 Dec 2004 02:04:07 Christian Sen replied:
Thank you, Simon <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 05 Dec 2004 15:48:53
05 Dec 2004 15:48:53 Christian Sen replied:
In case anybody is wondering how this is done:

Wrap it all into a script-function in your body section

window.onload = function()
{
var inputCollection = document.getElementsByTagName("input";
for(var i = 0; i &lt; inputCollection.length; i++)
{
var controlType = inputCollection[i].getAttribute('type');
if(controlType.toLowerCase() == 'text')
{
inputCollection[i].focus();
return;
}
}
}

This script is supposed to set focus to the first element on your side
where input is needed, for ex the login box with the username textfield.

Have tested this myself and it worked out just fine!
Replied 05 Dec 2004 18:35:41
05 Dec 2004 18:35:41 Dave Thomas replied:
or you can just set focus on the field in the body tag like so :

<pre id=code><font face=courier size=2 id=code>
onLoad="document.formname.fieldname.focus()"
</font id=code></pre id=code>

and change "fieldname" to match your textbox name.

Regards,
Dave

[DWMX 2004]|[FlashMX 2004 Pro]|[SQL]|[Access2000]|[ASP/VBScript]|[XP-Pro]


Edited by - UltraDav on 05 Dec 2004 18:36:22
Replied 05 Dec 2004 18:48:17
05 Dec 2004 18:48:17 Christian Sen replied:
Yepp, that would be much easier <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Replied 10 Dec 2004 20:09:56
10 Dec 2004 20:09:56 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>or you can just set focus on the field in the body tag like so :
<pre id=code><font face=courier size=2 id=code>onLoad="document.formname.fieldname.focus()"</font id=code></pre id=code>
and change "fieldname" to match your textbox name.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Yup. Also, I think someone released a freebie extension on &lt;a href="www.macromedia.com/exchange/"&gt;Macromedia.com/exchange/&lt;/a&gt;...<i>If</i> I remember right. <img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>

~~~~~~~~~~~~~~~
Chris Charlton

Sr. Developer - www.fingerprintMedia.com

Reply to this topic