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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5c27aa958030eed6817e4b2295d2040b?d=identicon&s=25 Ja Bo (jabo)
on 2006-12-30 19:59

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

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 !
72f8ab180f81f9c544e2b58da399c0be?d=identicon&s=25 Elad Meidar (eizesus)
on 2006-12-30 23: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.