Forum Moderators: phranque

Message Too Old, No Replies

Auto clear of search box content

When cursor put into box

         

Angonasec

1:20 am on Jun 9, 2006 (gmt 0)



I need code to automatically clear a search box of content when the cursor is put there. (Should b html4 strict). My current code purposely has Search in the box as default, but I'd like it to disappear when the cursor is put in the box to do the first search:

<form method="get" action="http://www.example.com/cgi-bin/search/search.pl">
<input name="Terms" id="fdse_TermsEx" SIZE="19" value="Search" />
<input type="image" src="i/go.gif" value="Search" />
</form>

Ta!

MichaelBluejay

6:10 am on Jun 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<input name="Terms" id="fdse_TermsEx" SIZE="19" value="Search" onFocus="if (this.value=='Search') this.value='';"/>

Be careful: this.value='' is two single quotes (apostrophes)

The bit after that is a double quote (quotation mark).

Copy and paste instead of retyping and you won't go wrong.

Angonasec

3:38 pm on Jun 9, 2006 (gmt 0)



Thank you Sir!

Works a treat.