PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > Web Site Design > HTML/CSS/Javascript
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
Old 10-14-09, 08:53 PM   #1
sammiedawg
 
Join Date: Aug 2004
Location: syracuse
Posts: 322
Reputation: 5
Search Bar Question

I have a search bar that says "Search here"

How can I have it so when the user clicks the search bar, the "Search here" text disappears?

thanks!!
sammiedawg is offline   Reply With Quote
Old 10-14-09, 10:36 PM   #2
satis
 
satis's Avatar
 
Join Date: Oct 2002
Location: Dallas
Posts: 2,659
Reputation: 204
javascript. Let's say this is your search bar

<input text="search here">

you can put javascript in there to detect when someone focuses on the box

<input text="search here" onfocus="this.value=''">

that's this.value='' (two single quotes). Basically, when focus is moved to the control, javascript takes this (the input box) and sets its value to '' (nothing).

The negative here is that if someone types something into it, then clicks away, then clicks back, the text gets wiped again. If that becomes a problem (99% of the time it wouldn't be) you can work around it, but I'd probably start moving to a function solution rather than doing it inline in the element.

Hope that helps.
__________________
Satis Clankiller
Clankiller.com Forums
Clankiller.com
PlasmaSky.com
satis is offline   Reply With Quote
Old 10-14-09, 10:38 PM   #3
Croc Hunter
Mod.. with bite..
 
Croc Hunter's Avatar
 
Join Date: Sep 2002
Location: Australia
Posts: 6,630
Reputation: 383
Here's an example. The third line specifically.
Code:
<form method="get" id="top-search" action="http://www.your-domain.com/"> <fieldset> <input type="text" id="top-s" name="s" value="Type text to search here" class="input-text"/> <input type="submit" id="top-search-submit" value="Search" class="input-submit"/> </fieldset> </form>
__________________
Croc Hunter MSC :
Croc Hunter is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 11:36 PM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright © 2000-2007 Jelsoft Enterprises Limited.