wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-17 18:47 UTC
Clear text_area value onfocus
Hi! I have a "text_area" that looks like this... <%= text_area ''business'', ''otherDigitalDesc'', "cols" => 25, "rows" => 4, "value" => "Enter Description if Yes..." %> Right now, if I submit it, it adds "Enter Description if Yes" into the database. It would be nice to not have it enter this, but if a user clicks on the box, it clears this out. I''m thinking of using onfocus, but my only fear is that if somebody clicks off and then back onto the box, won''t it clear their description? Is there a better/easier way to do this? Thanks, mike --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
louismrose-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Aug-17 19:41 UTC
Re: Clear text_area value onfocus
Hey! How about this: "onfocus" => "this.value=''''; this.onfocus=null;" I can''t claim credit for this; I stole it from: http://www.webmasterworld.com/forum91/3145.htm Hope it helps though! - Louis. On Aug 17, 7:47 pm, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! > > I have a "text_area" that looks like this... > > <%= text_area ''business'', ''otherDigitalDesc'', "cols" => 25, "rows" => > 4, "value" => "Enter Description if Yes..." %> > > Right now, if I submit it, it adds "Enter Description if Yes" into the > database. It would be nice to not have it enter this, but if a user > clicks on the box, it clears this out. I''m thinking of using onfocus, > but my only fear is that if somebody clicks off and then back onto the > box, won''t it clear their description? Is there a better/easier way > to do this? > > Thanks, > mike--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I would like to do the same thing. It would be nice to not have to have a label for the text field in some circumstances. I''ve seen this done really well but I can''t find a way to do it properly in rails. I don''t know what to even search for. Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-20 16:54 UTC
Re: Clear text_area value onfocus
Hi! Thanks for the information. This actually works really well....but now I have a second/original problem. How do I make it so that "Enter Description if Yes" does not get entered into the database, while a real answer does? For example, if nobody clicks on the textboxes, it will enter "Enter Description if Yes" into the db. Is there something in the model or controller I can say "if value = "Enter Description if Yes" { don''t put in } else { put in db}"? Thanks! Mike On Aug 17, 2:41 pm, "louismr...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" <louismr...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hey! > > How about this: > > "onfocus" => "this.value=''''; this.onfocus=null;" > > I can''t claim credit for this; I stole it from:http://www.webmasterworld.com/forum91/3145.htm > > Hope it helps though! > > - Louis. > > On Aug 17, 7:47 pm, "wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi! > > > I have a "text_area" that looks like this... > > > <%= text_area ''business'', ''otherDigitalDesc'', "cols" => 25, "rows" => > > 4, "value" => "Enter Description if Yes..." %> > > > Right now, if I submit it, it adds "Enter Description if Yes" into the > > database. It would be nice to not have it enter this, but if a user > > clicks on the box, it clears this out. I''m thinking of using onfocus, > > but my only fear is that if somebody clicks off and then back onto the > > box, won''t it clear their description? Is there a better/easier way > > to do this? > > > Thanks, > > mike--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---