On Fri, 07 May 2004 16:43:56 -0400, Brian
<usenet3@julietremblay.com.invalid> wrote:
[color=blue]
> Mick White wrote:
>[color=green]
>> document.forms[category].q.focus()[/color]
>
> I'm now using the following script:
>
> function changeFocus(category) {
> document.forms[category].q.focus();
> return false;
> }
>
> and the following html (edited for space):
>
> <A onClick="changeFocus('basicsearch')"
> HREF="#basic">basic site search</A>
>
> <A onClick="changeFocus('advancedsearch')"
> HREF="#advanced">advanced site search</A>
>
> <H2 id="basic">basic site search</H2>
>
> <FORM METHOD="get" ACTION="/foo/bar.pl" NAME="basicsearch">
> <INPUT TYPE="text" NAME="q">
> </FORM>
>
> <H2 id="advanced">advanced site search</H2>
> <FORM METHOD="get" ACTION="/foo/bar.pl" NAME="advancedsearch">
> <INPUT TYPE="text" NAME="q">
> </FORM>[/color]
You need to cancel the navigation for the focus to take effect (it also
acts very strangely on Mozilla, otherwise). Prefix the onclick attribute
value with "return " so that the "return false" statement in the
changeFocus() function passes back to the intrinsic event.
Mike
--
Michael Winter
M.Winter@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)