Forum: Ruby on Rails How to make the text_field default value disappear

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ja B. (Guest)
on 2006-12-30 20:59
Hello,

I have the following code :
  <%= text_field "company", 'name', {:type =>"text", :value => "Name of
company", :style => "width:130px"}  %>

This generates a text_field with the default value "Name of company" in
black...

What I would like is ...

Name of company would automatically disappear when a user wants to fill
out the text_field...

Anyone ?

Thank you very much !
Elad M. (Guest)
on 2006-12-31 00:03
(Received via mailing list)
Hi Ja, (Great name :))
Rails is a server side handler, it cannot handle anything on client
<--> browser <--> server cycle.
In your case, you need to set a JavaScript onFocus even for the
specific text field, and set it's value to "".
This topic is locked and can not be replied to.