Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   Javascript Search Box Help (http://www.go4expert.com/forums/javascript-search-box-help-t6433/)

Talks_44 19Sep2007 21:54

Javascript Search Box Help
 
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

pradeep 20Sep2007 10:33

Re: Javascript Search Box Help
 
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>


Talks_44 21Sep2007 20:39

Re: Javascript Search Box Help
 
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...!!!


All times are GMT +5.5. The time now is 17:39.