Setting focus to search page input field

D

Dave Rado

Hi

I have been the following code by Freefind to use on my search page:

<form action="http://search.freefind.com/find.html" method="get"
accept-charset="utf-8" target="_self">
<input type="hidden" name="id" value="[unique id for my website]">
<input type="hidden" name="pageid" value="r">
<input type="hidden" name="mode" value="all">
<input type="hidden" name="n" value="0">
<input type="hidden" name="_charset_" value="">
<input type="hidden" name="bcd" value="÷">
<input type="text" name="query" size="15">
<input type="submit" value=" Find "></form>

It works great, but want to set the focus to the search textbox when
the page loads so that the user can start typing, using <body onload
="document.getElementById('ScrollableContent').focus()">, but I can't
see any id for the search textbox in the code I've been given.

How can I set the focus to the search textbox when the page loads?

Dave
 
D

Dave Rado

Sorry typo in my previous post, I meant to write:

It works great, but I want to set the focus to the search textbox when
the page loads so that the user can start typing straight away, using
<body onload="document.getElementById('[id of textbox]').focus()">

Dave
 
J

Joost Diepenmaat

Dave Rado said:
Hi

I have been the following code by Freefind to use on my search page:

<form action="http://search.freefind.com/find.html" method="get"
accept-charset="utf-8" target="_self">
<input type="hidden" name="id" value="[unique id for my website]">
<input type="hidden" name="pageid" value="r">
<input type="hidden" name="mode" value="all">
<input type="hidden" name="n" value="0">
<input type="hidden" name="_charset_" value="">
<input type="hidden" name="bcd" value="÷">
<input type="text" name="query" size="15">
<input type="submit" value=" Find "></form>

It works great, but want to set the focus to the search textbox when
the page loads so that the user can start typing, using <body onload
="document.getElementById('ScrollableContent').focus()">, but I can't
see any id for the search textbox in the code I've been given.

Just add one:

<input type="text" name="query" id="ScrollableContent" size="15">

Though you should probably use a more meaningful ID.
 
D

Dave Rado

I've worked out the answer - I just needed to change to form's code
from:

<input type="text" name="query" size="15">

to <input type="text" name="query" id="query" size="15">

.... and then use the id "query" in my onload statement.

Sorry about that.

Dave
 
D

Dave Rado

Though you should probably use a more meaningful ID.

Yes, that was a typo, sorry (see my earlier replies to my original
post, which I was typing while you were typing your reply).

Thanks, and apologies for posting before I'd put enough thought into
trying to solve it myself.

Dave
 
J

Joost Diepenmaat

Dave Rado said:
Yes, that was a typo, sorry (see my earlier replies to my original
post, which I was typing while you were typing your reply).

Thanks, and apologies for posting before I'd put enough thought into
trying to solve it myself.

No problem. Sometimes it just works best to step back a bit to think
things over.

Cheers,
Joost.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top