Forum Moderators: coopster

Message Too Old, No Replies

Search Text - click to make value text dissapear

Search Text - click to make value text dissapear

         

oldworldcharms

6:52 pm on Jul 4, 2005 (gmt 0)

10+ Year Member



I am using php for my site and in the header I have the code below for the search box. Inside the search box I have Enter Keywords. Does anyone know how I can make the text dissapear when a user clicks inside the search box once?

Thanks
Elizabeth

<form name="quick_find" method="get" action="../advanced_search_result.php">
<input type="hidden" name="search_in_description" value="1">
<P style="margin-bottom: 0">Search <input type="text" name="keywords" size="8" maxlength="30" value="Enter Keywords" style="width: 115px"><INPUT type="image" alt="Search" src="../images/icons/go_s.gif" align="middle" value="Search" border="0" name="I5"></P>
<TABLE border="0" cellspacing="0" width="100%" >
<TR>
<TD width="100%" class="headercart"><IMG border="0" src="/images/icons/cart_bask.gif"> $cartcontents</TD>
</TR></TABLE></form>

mcibor

7:56 pm on Jul 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to use js script onfocus

like this. In head:

<script language="JavaScript" type="text/javascript">
<!--
function clear_text(object) {
object.value = "";
object.focus();}
//-->
</script>

then in input:
<input type="text" name="keywords" size="8" maxlength="30" value="Enter Keywords" style="width: 115px" onfocus="clear_text(this);">

This should work. If not, then ask this on javascript forum. In php it's impossible to do, as it's only server side language.

best regards
Michal Cibor

oldworldcharms

8:05 pm on Jul 4, 2005 (gmt 0)

10+ Year Member



Thanks for replying so fast. I will try this but I have been trying to avoid using javascript for google purposes. so will this still work using js code? Now to remember how to do that, thanks again