Forum Moderators: open

Message Too Old, No Replies

How to erase prefilled text

in a search form

         

wrgvt

5:37 pm on Nov 24, 2006 (gmt 0)

10+ Year Member



I was thinking this has to be pretty easy, but I guess my ignorance of javascript is working against me. I have a simple search box, and I prefill it with something like "Enter search terms." When someone clicks the search box, I want the "Enter search terms" to erase so they can enter their own search terms.

My form would have the following parts:

<input type="TEXT" name="query" value="Enter search terms">
<input type="SUBMIT" value="Search">

But with this method, they have to erase the prefilled text to enter their own search terms.

eelixduppy

5:40 pm on Nov 24, 2006 (gmt 0)



<input type="TEXT" name="query" value="Enter search terms" [b]onClick="this.value='';"[/b]>

:)

Bernard Marx

6:09 pm on Nov 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



May I recommend cancelling the clearance after the first onclick, or the feature could become an annoyance, due to minor amendments being impossible.

onclick="this.value='';this.onclick=null;"

wrgvt

6:39 pm on Nov 24, 2006 (gmt 0)

10+ Year Member



Thanks so much! It works like a dream.