Click to See Complete Forum and Search --> : Focus on a field when loaded


Jills2000
10-13-2004, 07:54 PM
Hi,

I would like to automatically have the focus on a particular form element when my HTML page loads, but am not sure how to do this. Is there a particular keyword like FOCUS or something that allows a programmer to specify what field should have the default focus?

I don't really know where to begin looking for this and would really appreciate it if anyone could head me in the right direction! :confused:

Thanks in advance,
Jill

steelersfan88
10-13-2004, 08:06 PM
You will probably have to use JS for this, but you might want to look into the tabindex (http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex) attribute (if an input object).<script type="text/javascript">
onload = function() {
document.getElementById('elem').focus();
}
</script>