Robert Walker wrote in post #955914: > Leonel *.* wrote in post #955832: >> What I want to accomplish is something similar to the LOCATION field at >> www.krop.com Do you see how it reads Live Search inside the box? As soon >> as you click on it, it disappears allowing you to enter your search >> terms. >> >> How can I accomplish the onclick="" event with a form helper in Rails or >> some other Rails way? >> >> I have a login form: Username and Password. The Username field is >> supposed to say "Username" and when you click on the field "Username" >> disappears, allowing you to enter the Username. > > This is mostly for future reference, but HTML 5 offers this feature > without requiring any JavaScript at all: > > <form action="/" method="get" accept-charset="utf-8"> > <p><input type="search" name="search" placeholder="Search"></p> > <p><input type="text" name="username" placeholder="Your username"> > </form> > > Notice the placeholder attribute.
Excellent! I think I'll start using that. And then one doesn't need an onclick attribute: just have JS read the placeholder attribute and act accordingly to provide the functionality for browsers that don't have it. Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

