473,791 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making default entry in search text box disappear on click

Hi All

How do I make it so that when a user clicks in a search text field, the
default entry (in this case "Search") is removed automatically - they
are then faced with a blank search box and can type straight away

Thanks in advance

Jul 24 '05
36 72092
"Alan J. Flavell" wrote:
On Wed, 6 Jul 2005, Philip Ronan wrote:
"Jukka K. Korpela" wrote:
You never heard of such holes? Not very real.


OK please explain what's so insecure about using Javascript to clear the
initial contents of a search box.


What's insecure is allowing an untrusted site to execute javascript on
one's browser. The intended purpose is irrelevant for this. If you
don't yet know this, then you aren't in a position to argue about it.


So ... you're saying that web designers should never use Javascript on the
WWW, because the visitors to their websites will end up running these
scripts on their browsers.

I'm afraid you lost me there. Can you explain how your argument differs
logically from the statement that newsagents should never sell matches
because people that buy them might set themselves on fire?

Perhaps you're confusing "Javascript " with "Java"?

Surely you know how to disable Javascript in your browser. So if you're
really concerned about this then there's a simple solution. I used to keep
it switched off to prevent pop-up ads from appearing, but that was about as
bad as it got. Now I have a browser that blocks pup-ups automatically.

But to return to the topic of this discussion, the OP's search box is still
going to be perfectly usable with Javascript disabled, so nobody's being
excluded. Most visitors (i.e., the ones that have Javascript enabled) will
see things working as intended. The others will be held up by about 1 second
because they will need to delete the pre-filled text. Is that such a big
deal?

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 24 '05 #11
On Wed, 6 Jul 2005, Philip Ronan wrote:
What's insecure is allowing an untrusted site to execute javascript on
one's browser. The intended purpose is irrelevant for this. If you
don't yet know this, then you aren't in a position to argue about it.
So ... you're saying that web designers should never use Javascript on the
WWW,


No, I'm not saying that. I'm saying that the design should never
*rely* on javascript being successfully executed. Using it to provide
optional extra conveniences is perfectly fine.

Keep in mind, additionally, that none of the indexing robots will be
executing your javascript, so anything which *relies* on javascript to
reach a particular resource will not get indexed properly.
Perhaps you're confusing "Javascript " with "Java"?


You're very rude.

Jul 24 '05 #12
Philip Ronan <in*****@invali d.invalid> wrote:
Did you have something to say about HTML authoring for the WWW?
Sure.


Let's see.
If you want to add a search box to your web pages but you
don't have much space available, here's something you could try:
Create a form with a single INPUT box containing "Search" as the
initial text.


What you should _do_ is to make space, by abandoning wrong ideas about
squeezing essential elements into the size of a small stamp. Do, or do
not; there is no try.

Using "Search" as initial text is simply wrong, since it's defined as
_default_ text. It does not solve the space problem. It does not make
it clear that it is a search box; it is _not_ a label, but initial
content.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #13
"Jukka K. Korpela" wrote:
Philip Ronan <in*****@invali d.invalid> wrote:
If you want to add a search box to your web pages but you
don't have much space available, here's something you could try:
Create a form with a single INPUT box containing "Search" as the
initial text.
What you should _do_ is to make space, by abandoning wrong ideas about
squeezing essential elements into the size of a small stamp. Do, or do
not; there is no try.


I don't recall mentioning postage stamps anywhere. In fact this technique
could actually help to free up space so that things *don't* have to be made
excessively small. What's wrong with that?
Using "Search" as initial text is simply wrong, since it's defined as
_default_ text.
Where exactly is this definition you're referring to? In the HTML 4.01
specification, it says:
value = cdata [p.50] [CA] [p.49]
This attribute specifies the initial value [p.220] of the control.
It is optional except when the type attribute has the value "radio"
or "checkbox".
It mentions an "initial value" there, but I can't see the word "default". In
case you're interested, all it says on page 220 is:
In general, a control's "initial value" may be specified with the
control element's value attribute.


Again, it doesn't say anything about this being the "default" value.
It does not solve the space problem.
How so?
It does not make it clear that it is a search box;
Just how clear do things have to be? I think anyone with a brain would be
able to figure it out. What else do you suppose people might mistake this
search box for?
it is _not_ a label, but initial content.


Yes, that's correct. In fact you might like to call it an inventive usage of
initial content that eliminates the need for a label. I'm guessing you might
not, however :-(

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 24 '05 #14
"Jukka K. Korpela" wrote:
it is _not_ a label, but initial content.

Philip Ronan <in*****@invali d.invalid> wrote: Yes, that's correct. In fact you might like to call it an inventive usage of
initial content that eliminates the need for a label. I'm guessing you might
not, however :-(


Rather than using "Search" as the initial content of the text field (and
then having to deal with the problems that creates), why not just use
"Search" as the label on the submit button? It's clear, it's expected, it's
simple, it works for everyone, and it has no unpleasant side effects.
--
Darin McGrew, mc****@stanford alumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp. com, http://www.HTMLHelp.com/

"Cheaters never win; they just finish first." - Johhny Hart
Jul 24 '05 #15
Philip Ronan <in*****@invali d.invalid> wrote:
It mentions an "initial value" there, but I can't see the word
"default".


Look for meanings, not words. The "initial value" is the value that is
submitted along with other form data, unless the value is changed.
The common way of expressing this fact is the phrase "default value".

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #16
"Jukka K. Korpela" wrote:
Philip Ronan <in*****@invali d.invalid> wrote:
It mentions an "initial value" there, but I can't see the word
"default".


Look for meanings, not words. The "initial value" is the value that is
submitted along with other form data, unless the value is changed.
The common way of expressing this fact is the phrase "default value".


Meanings. OK then. In your last post you said that using "Search" as initial
text is "... simply wrong because it's defined as default text". So where
*is* this definition? Is it perhaps just a figment of your imagination? If
so, then the meaning of your argument is basically "It's simply wrong
because I say so."

I daresay the word "Search" probably wouldn't be used as a search term very
often. An empty string isn't a particularly useful search term either. But
as I keep saying, in this case the initial text is there to identify the
purpose of the search box, so it's serving a useful purpose.

It's also perfectly useable, valid HTML. So why all the fuss?

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 24 '05 #17
"Darin McGrew" wrote:
"Jukka K. Korpela" wrote:
it is _not_ a label, but initial content.


Philip Ronan <in*****@invali d.invalid> wrote:
Yes, that's correct. In fact you might like to call it an inventive usage of
initial content that eliminates the need for a label. I'm guessing you might
not, however :-(


Rather than using "Search" as the initial content of the text field (and
then having to deal with the problems that creates), why not just use
"Search" as the label on the submit button? It's clear, it's expected, it's
simple, it works for everyone, and it has no unpleasant side effects.


You can do that if you like.

You can also omit the submit button altogether. The form can still be
submitted without it. And without any unpleasant side-effects apart from
getting roasted in this NG.

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 24 '05 #18
Philip Ronan <in*****@invali d.invalid> wrote:
Meanings. OK then. In your last post you said that using "Search"
as initial text is "... simply wrong because it's defined as
default text". So where *is* this definition?


In the HTML specification, as I explained. Did you already forget to
look for meanings, not words?

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #19
Philip Ronan <in*****@invali d.invalid> wrote:
You can also omit the submit button altogether. The form can still be
submitted without it.


Well, yes. And windows can still be scrolled even when the author removes
the scrollbars.

But it doesn't seem very user-friendly to remove the most obvious and most
familiar mechanisms for submitting a form or scrolling a window.
--
Darin McGrew, mc****@stanford alumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp. com, http://www.HTMLHelp.com/

"Cheaters never win; they just finish first." - Johhny Hart
Jul 24 '05 #20

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

Similar topics

1
3169
by: shantibhushan | last post by:
Hi buddy I have to highlight search text from search results as it is in google or alibaba.com. e.g. if I input paper as a searchtext in search results paper word should be highlighted. as it isin google help. some one help me please. I am working in asp.net2.0 using c# Regards,
0
957
by: Ivica Muruzovic | last post by:
How can I use previous typed search text in google search box or any other web browser. I have combobox and want to fill him with that previous typed search text on local machine
4
6843
by: sangam56 | last post by:
Hi all. I have an iframe in an asp.net web page (Display.aspx). <iframe id="iframe1" runat="server" src="temp/test.html"></iframe> Now I need to highlight a search text, say 'test' in the Display.aspx page. The source of iframe is dynamically assigned and search text is also changeable. This means I am dealing with dynamic search text and html page. Please suggest me how could I highlight the search texts in the iframe placed in the...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
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
10426
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
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9029
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
7537
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
6776
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
5430
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...
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.