Hi all, I have this text_field that needs to be filled out before a form can be submitted. To do this I added an :onchange attribute that basically checks to see if the value of the field is blank, if it is then the submit button on the form gets hidden, else it is shown. The idea also being that if the user enters a value, the button should be shown, but if that value is deleted, the button should be removed from the page as well. Here is my code: <%= text_field ''param'', ''category'', {:onchange => ''document.getElementById(\''param_category\'').value != "" ? document.getElementById(\''go_button_div\'').style.display \''inline\'' : document.getElementById(\''go_button_div\'').style.display \''none\'';''} %> It works, but not exactly as desired. I would like this to show the button even if a single character is entered and then hidden if it is deleted. As it is now, the button is only displayed when the text_field is not on focus, which for my purposes does work but I feel this could be confusing and irritating to the end user. Am I mistaken in thinking that the using :onchange should give me this effect, or is there an error in my code? It almost seems like :onchange and :onfocus are working in the same manner in this example. Thanks, -S -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
:onkeyup does what I want. wouldn''t you know no more than five minutes after I post this a light goes on and I figure it out. -S -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
try to go unobstrusive On Thu, Sep 9, 2010 at 5:46 PM, Shandy Nantz <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> :onkeyup does what I want. wouldn''t you know no more than five minutes > after I post this a light goes on and I figure it out. > > -S > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.