How to make the text_field default value disappear



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 !


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 “”.