[thelist] onFocus

Arthur Noel adn at clara.net
Tue Oct 30 12:58:44 CST 2001


> I would like to have the cursor focus in the input box. What 
> is wrong with
> this statement?
> 
> <form name="srchfrm" method="get" action="engine.htm"
> onFocus="window.document.srchfrm.srchtxt.focus();"
> onSubmit="check(this.srchtxt);" target="_top">
> <input type="text" size=30 name="srchtxt">

Do you mean you want the box to be focussed when the page is loaded? If
so put a script block in the <head> containing the following:

window.onload = function() {
    document.srchfrm.srchtxt.focus();
    }

and then change your form to read as follows:

<form name="srchfrm" method="get" action="engine.htm"
onSubmit="check(this.srchtxt);" target="_top">
<input type="text" size=30 name="srchtxt">
...

I'd also have a look at your onsubmit normally you'd have something like
onsubmit="return check(this.srchtxt)" where your check function returns
a boolean result.

Hope that helps,
Arthur







More information about the thelist mailing list