[pmwiki-users] searchbox that clears

adam overton a at plus1plus1plus.org
Sun Apr 8 19:58:24 CDT 2012


hi friends
i want to make a searchbox that says "search" in the field, but that then automatically clears when it's clicked upon. i only want this for the searchbox on some pages, not all.

is there away to make this happen with (:searchbox:)? or with regular (:input:)'s? i can't figure it out.

i currently have the following code installed in config that causes inputs with a name like "myInput-clear" to clear when clicked upon:

$InputTags['searchbox'][':html'] = "<input type='text' \$InputFormArgs  
    onfocus=\"if(this.name.indexOf('-clear')!=-1) this.value=''\" />";

in the case of (:searchbox:), i can't figure out how to add -clear to it's name.
and in the case of (:input:), i can easily add -clear to the name, but i can't figure out how to make it do the search i want, and to pass the value.

ideally i'd like to insert some javascript like this:
<input type="text" name="field-name-here" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Enter Email To Get Updates':this.value;" value="Enter Email To Get Updates" />

... but somehow i'm not comprehending the PmWiki instructions posted here: http://www.pmwiki.org/wiki/Cookbook/InputFormsAndJavaScript

thanks for any advice!
adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20120408/2f26d2b4/attachment.html>


More information about the pmwiki-users mailing list