[pmwiki-users] searchbox that clears
a at plus1plus1plus.org
Mon Apr 9 02:20:13 CDT 2012
oops, i think this one works a little better:
$InputTags['text'][':html'] = "<input type='text' \$InputFormArgs
onfocus=\"if(this.getAttribute('class').indexOf('clear')!=-1) holdValue=this.value; this.value=''\"
onblur=\"if(this.getAttribute('class').indexOf('clear')!=-1 && this.value=='') this.value=holdValue;\" />";
the previous one worked if you typed in a search term and hit enter, keeping the focus on the inputbox; problem was if you clicked the submit button - the focus would move and the contents of the input box would get cleared. this fixes that. but if you type some, and then leave the field, and then return, the previous work disappears. oh well, maybe works good enough for now.
On 9 Apr 2012, at 12:05 AM, adam overton wrote:
> well, after much toil, this is what i came up with to solve my problem. i still wonder if there is a simpler method than this?
> in config:
> # this checks to see if the input has "clear" in the class-attribute, i.e. class="searchbox clear" would trigger it
> $InputTags['text'][':html'] = "<input type='text' \$InputFormArgs
> onfocus=\"if(this.getAttribute('class').indexOf('clear')!=-1) holdValue=this.value; this.value=''\"
> onblur=\"if(this.getAttribute('class').indexOf('clear')!=-1) this.value=holdValue;\" />";
> in PmWiki, i figured out how to make a form that duplicates (:searchbox:):
> (:input form class="wikisearch" action="http://mysite.com/Search/index" method=get:)
> (:input hidden name='target' value='Search/':)
> (:input hidden name='list' value='nocoregroups':)
> (:input hidden name='fmt' value='#SearchPageFmt':)
> (:input hidden name='action' value="search":)
> (:input text class="inputbox searchbox clear" name="q" value="search" size="19" default="search":)
> (:input submit value="go" class="searchbutton":)
> (:input end:)
> again, would be nice to figure out how to add a class of "clear" to a searchbox, but found that (:searchbox ... class="clear searchbox" adds the class to the <input form..., not to the actual text field...
> On 8 Apr 2012, at 5:58 PM, adam overton wrote:
>> 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.
>> <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" />
>> thanks for any advice!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pmwiki-users