How to position the cursor in a text box in HTML page?

Carl Uman

Diamond Member
Jan 29, 2000
6,008
2
81
I need to set the cursor to be in a text box by default when I open a page. How can this be done in HTML? Also how can I set a button to have focus by default when opening a page (I assume the same way)?

Thanks,
Carl
 

RedRooster

Diamond Member
Sep 14, 2000
6,596
0
76
Javascript.

Search on how to change focus with javascript, and you'll find the code you need.
Ex.


document.forms[0].CATEGORY.focus();


oops, forgot to mention, you'll need an onLoad event in the body tag that calls the function that contains the code I gave you. Just put onLoad="functionname()" in the body tag as well.