473,657 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting focus to search page input field

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.getE lementById('Scr ollableContent' ).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
Jun 27 '08 #1
5 2255
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="documen t.getElementByI d('[id of textbox]').focus()">

Dave
Jun 27 '08 #2
Dave Rado <da*******@dsl. pipex.comwrites :
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.getE lementById('Scr ollableContent' ).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="ScrollableC ontent" size="15">

Though you should probably use a more meaningful ID.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #3
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
Jun 27 '08 #4
On Apr 15, 12:22 am, Joost Diepenmaat <jo...@zeekat.n lwrote:
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
Jun 27 '08 #5
Dave Rado <da*******@dsl. pipex.comwrites :
On Apr 15, 12:22 am, Joost Diepenmaat <jo...@zeekat.n lwrote:
>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.
No problem. Sometimes it just works best to step back a bit to think
things over.

Cheers,
Joost.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14281
by: fish | last post by:
Hi, I have an HTML page with a FORM and some input fields. On the fields I wish to do validation as the punters change the field values. If they get it wrong, then I tell them and then wish to put the focus back to the offending field. ( It works if a use an 'onblur' event but not an 'onchange' )
11
4473
by: JCO | last post by:
I have a text box, on my form that I cant get the focus on. I'm using it as shown: <head> <body onload=document.getPassword.txtPasswordName.focus()> </head> Where getPassword is the form & txtPasswordName is the text box
2
7511
by: dsnyder | last post by:
This HTML has a bit of Javascript at the end that puts the initial focus on the userID field. It works great on Windows2000 running IE6, but the initial focus never goes to the userID field on Windows 2003 PocketPC (Windows Mobile) running Pocket IE. <html><head><title>WMS - P280WF100 - Login</title><META HTTP-EQUIV='expires' VALUE='0'> </head> <body> <form name="frmLogon" action='p280wp100' method='get'>
6
14443
by: Csaba | last post by:
I'd like to have the cursor in the login form's username input text field when users load the login page. It works fine with the following implementation: <body onload="document.login.username.focus();"> <form name="login" method="post" action="<?=$PHP_SELF?>"> <input type="text" name="username" onLoad="self.focus();"> The problem is that the input field's name cannot be simly "username", because it posts an element of an array,...
7
30407
by: ScooterMX | last post by:
I've seen where login pages (and other form-based pages) place the cursor in the first field of a form after the page loads. I'm familiar with the tabIndex, but that only works once you hit the tab key. What function automatically places the cursor in any give form field??
3
8311
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There are a couple of people selling components... but that is not really an option for me... So, I took the plunge and modified the "WebUIValidation.js" file to make it happen... After tracing through file, I figure it out. It was actually pretty...
5
2502
by: jose1lm | last post by:
What is supposed to happen: A user enters data into one of the FORM input selections. When the user submits the form, the onclick event is supposed to go to a function that will set another FORM value (SearchSel) to some number that will be used on the next page. The javascript function 'setSelx' doesn't work in FireFox but works with the other browsers. Can someone help to fix this code or point me in the right direction? Server:...
4
1895
Claus Mygind
by: Claus Mygind | last post by:
I am creating an element dynamically as I load it on the screen. When it was hard coded on the page I had no problem executing the following two lines. document.getElementById("SEARCH").select(); document.getElementById("SEARCH").focus(); Now I create the element the following way (see below) in my js function followed by the two lines above. I get no error message, but the input field has not received focus. td.innerHTML...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.