PDA

View Full Version : Form Element Focus


Archangel
04-08-2005, 03:42 PM
I believe this is in the realm of java...if not I apologize.

I have a form text field and a submit button. Once the fill in the text field and hit submit it writes that data to a DB (via ASP) then reloads the page displaying the inputed data as well as another empty text field for them to input more data.

However, once the page reloads they either have to click on the empty field or hit the tab to go to it. Is there anyway so when the page reloads this field automatically gets focus so they can just start typing?

Thanks!

BaldEagle
04-17-2005, 11:24 AM
If there is only one text box on the form at a given time you can use an onload event to set the focus (actually you can do it this way even if there are multiple text boxes but will require more coding).

<script type=javascript>
function setFocus()
{
document.forms[0].some_text_box_name.focus();
}
</script>

<body onload="setFocus()">

BaldEagle