Forum: Ferret default text in search text field

Posted by 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
Posted by 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
Posted by 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.