Javascript Search Box Help

Talks_44's Avatar, Join Date: Sep 2007
Go4Expert Member
Hi Guys,

i spoke to ben about this before, and i thought i would try and have a go at it myself.

but as i do not know the first thing about javascript and not being able to find anything on the internet i thought i would ask here.

i currently have a product search box on my shop which is made up of the following HTML.

CODE


Code:
<h3>Product Search</h3>
<p></p>
<form action="index.asp?function=SEARCH" method="post">
<input name="search" type="text" value="Type Search Criteria + Enter" size="25" class="searchbox" />
</form>
<p></p>
as you can see i have it so that in the contents of the search box it says "Type Search Criteria + Enter" but the problem is the user has to delete all whats in the box before they type anything in

what i would like to happen is that when someone clicks in the search box it automaticly deletes "Type Search Criteria + Enter" allowing them to enter a product without having to delete anything.

also how hard is it to get the background colour of the search box to change?

Thanks in advance

Last edited by shabbir; 20Sep2007 at 09:46.. Reason: Code block
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Add an onfocus handler, on the search box!

Code: HTML
<h3>Product Search</h3>
<p></p>
<form action="index.asp?function=SEARCH" method="post">
<input name="search" type="text" value="Type Search Criteria + Enter" size="25" onFocus='this.value="";' class="searchbox" />
</form>
<p></p>
0
Talks_44's Avatar, Join Date: Sep 2007
Go4Expert Member
Quote:
Originally Posted by pradeep
Add an onfocus handler, on the search box!

Code: HTML
<h3>Product Search</h3>
<p></p>
<form action="index.asp?function=SEARCH" method="post">
<input name="search" type="text" value="Type Search Criteria + Enter" size="25" onFocus='this.value="";' class="searchbox" />
</form>
<p></p>
Thx mate...!!!