Forum: Ferret default text in search text field

2caf744c3db4756735fcbb79e777e014?d=identicon&s=25 Makoto Gim (makotogim)
on 2010-07-01 11:10
Hello,

I am trying to figure out how I can introduce a default text in my
searchbox that is removed automatically when the user tries to write
something.

Is this possible to do it with some kind of ferret command? The only way
I can find I can do it is with some javascript code.

Thanks in advance

Makoto
E5d4db2f53bec777e0d25acbeb3f706e?d=identicon&s=25 Veera Sundaravel (veeraa2003)
on 2010-09-22 09:05
Makoto Gim wrote:
> Hello,
>
> I am trying to figure out how I can introduce a default text in my
> searchbox that is removed automatically when the user tries to write
> something.
>
> Is this possible to do it with some kind of ferret command? The only way
> I can find I can do it is with some javascript code.
>
> Thanks in advance
>
> Makoto

Yes you have to use JS code to make it simpler and faster.


<input type="text" value="Search here..." onclick="clickclear(this,
'Search here...')" onblur="clickrecall(this, 'Search here...')"
name="search_term">

<script>
function clickclear(thisfield, defaulttext) {
  if (thisfield.value == defaulttext) {
  thisfield.value = "";
  }
}

function clickrecall(thisfield, defaulttext) {
  if (thisfield.value == "") {
  thisfield.value = defaulttext;
  }
}
</script>


--
Regards,

T.Veerasundaravel.
http://tinyurl.com/25vma7h
@veerasundaravel
2caf744c3db4756735fcbb79e777e014?d=identicon&s=25 Makoto Gim (makotogim)
on 2010-09-24 00:07
Hello Veera,

Thanks a lot, it worked perfectly!!!


regards

@makotogim

Veera Sundaravel wrote:
> Makoto Gim wrote:
>> Hello,
>>
>> I am trying to figure out how I can introduce a default text in my
>> searchbox that is removed automatically when the user tries to write
>> something.
>>
>> Is this possible to do it with some kind of ferret command? The only way
>> I can find I can do it is with some javascript code.
>>
>> Thanks in advance
>>
>> Makoto
>
> Yes you have to use JS code to make it simpler and faster.
>
>
> <input type="text" value="Search here..." onclick="clickclear(this,
> 'Search here...')" onblur="clickrecall(this, 'Search here...')"
> name="search_term">
>
> <script>
> function clickclear(thisfield, defaulttext) {
>   if (thisfield.value == defaulttext) {
>   thisfield.value = "";
>   }
> }
>
> function clickrecall(thisfield, defaulttext) {
>   if (thisfield.value == "") {
>   thisfield.value = defaulttext;
>   }
> }
> </script>
>
>
> --
> Regards,
>
> T.Veerasundaravel.
> http://tinyurl.com/25vma7h
> @veerasundaravel
This topic is locked and can not be replied to.