473,781 Members | 2,702 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 #1
36 72090
"spence" wrote:
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


<INPUT type="text" value="Search" onfocus="if
(this.value==th is.defaultValue ) this.value='';" >

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 24 '05 #2
Brilliant. Thanks philip.

I tried searching other groups but couldn't find a thing! Perhaps it
was my search criteria? Anyway, it's here now if anyone uses the same
search criteria I was using!

Thanks again

Jul 24 '05 #3
"spence" <be***********@ gmail.com> wrote:
Brilliant.
Really? You got a wrong answer. That's what you usually get by asking
in a wrong group. Dynamic modification of a field's content is not an
HTML matter.
I tried searching other groups but couldn't find a thing! Perhaps it
was my search criteria? Anyway, it's here now if anyone uses the same
search criteria I was using!


Well, maybe I then need to mention that the answer is wrong.

It is wrong because it relies on security holes in browsers (it does
not work if the browser has client-side scripting disabled), for doing
something that need not be done at all. A search box should have
initial content only if the initial content is a _meaningful and useful
default_. It would then be absurd to wipe it out.

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

Jul 24 '05 #4
Jukka K. Korpela wrote:
"spence" <be***********@ gmail.com> wrote:
Brilliant.


Really? You got a wrong answer. That's what you usually get by asking
in a wrong group. Dynamic modification of a field's content is not an
HTML matter.
I tried searching other groups but couldn't find a thing! Perhaps it
was my search criteria? Anyway, it's here now if anyone uses the same
search criteria I was using!


Well, maybe I then need to mention that the answer is wrong.

It is wrong because it relies on security holes in browsers (it does
not work if the browser has client-side scripting disabled), for doing
something that need not be done at all. A search box should have
initial content only if the initial content is a _meaningful and useful
default_. It would then be absurd to wipe it out.


If (and only if) there's really a good reason to do something like this, the
'default' (which is probably not a default at all..) should be removed and
*inserted* using scripting, so non-scripted clients just get a blank input.
I've seen too many form submissions like 'Your NameFred Smith' or 'Your
Em*******@examp le.com' (that was my hard way to learn that this is a bad
idea).
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Jul 24 '05 #5
"Jukka K. Korpela" wrote:
It is wrong because it relies on security holes in browsers (it does
not work if the browser has client-side scripting disabled), for doing
something that need not be done at all.


Get real. This has nothing to do with security holes.

If Javascript is disabled, then the user can delete it with a single
keypress. So what's the problem? Spare us the dogma, please!!

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 24 '05 #6
Philip Ronan <in*****@invali d.invalid> wrote:
"Jukka K. Korpela" wrote:
It is wrong because it relies on security holes in browsers (it
does not work if the browser has client-side scripting disabled),
for doing something that need not be done at all.
Get real. This has nothing to do with security holes.


You never heard of such holes? Not very real.
If Javascript is disabled, then the user can delete it with a
single keypress.
Can he? Are you sure?
So what's the problem?
There was no problem before someone created it by using a default entry
that ain't no default entry but just an annoyance.
Spare us the dogma, please!!


Did you have something to say about HTML authoring for the WWW?

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

Jul 24 '05 #7
"Jukka K. Korpela" wrote:
Philip Ronan <in*****@invali d.invalid> wrote:
"Jukka K. Korpela" wrote:
It is wrong because it relies on security holes in browsers (it
does not work if the browser has client-side scripting disabled),
for doing something that need not be done at all.


Get real. This has nothing to do with security holes.


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.
If Javascript is disabled, then the user can delete it with a
single keypress.


Can he? Are you sure?


OK, I have to admit I haven't tested this functionality in every single
browser. I've got better things to do, as it happens. But from my experience
most browsers select the contents of text boxes when they receive focus. If
not, then the user just has to hold the key down a bit longer until the
auto-repeat kicks in. Or if the user is really pressed for time, perhaps
control+delete might do it, or (gasp) control-A, delete. This isn't really a
big deal.
So what's the problem?


There was no problem before someone created it by using a default entry
that ain't no default entry but just an annoyance.


An annoyance to you perhaps, but you seem to be the sort of person that gets
annoyed very easily.
Spare us the dogma, please!!


Did you have something to say about HTML authoring for the WWW?


Sure. 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. That way you can
indicate the purpose of the search box without cluttering your design with
additional LABEL or LEGEND elements. You can even use Javascript to clear
this initial text when the text box receives the focus. Just don't tell
anyone at c.i.w.a.h what you've done.

Will that do?

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/

Jul 24 '05 #8
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.

Jul 24 '05 #9
"Alan J. Flavell" wrote:
You're very rude.
I'm sorry you think that way. I'm not *trying* to be rude. I'm just trying
to understand your point of view. I'm still confused.

You joined this thread by remarking that
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.
Then you "clarified" your position by stating 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.


Those viewpoints just aren't consistent. If you check back through this
thread, I think you'll find that my suggested solution to the OP's problem
doesn't *rely* on the availability of Javascript, because the initial text
can easily be deleted by other means. It also provides extra convenience for
users by eliminating the need for LABEL and LEGEND elements that might, in
some cases, have an adverse effect on the design of a web page.

So can you please tell me what I'm doing wrong and why I'm not in a position
to comment on this topic?

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 24 '05 #10

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

Similar topics

1
3168
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
956
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
9639
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
9474
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
10308
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
10143
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...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8964
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
7486
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
5375
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...
3
2870
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.