This code disables the ''Save'' button once clicked, but doesn''t seem to send the form data. <%= submit_tag ''Save'', :class => ''submit'', :onclick => "document.getElementById(''save_button'').disabled=true;", :id => "save_button" %> This code sends the form data and a record is created, but isn''t disabled once clicked. A user can click this many times, creating a new record each time. <%= submit_tag ''Save'', :class => ''submit'', :onclick => "document.getElementById(''save_button'').disabled=true;", :id => "save_button" %> Anyone know of a way to fix the javascript to disable the ''Save'' button and also send the form data when clicked once? Thanks, Frank -- 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.
Hi Frank, On Wed, 2010-01-20 at 22:44 +0100, Frank Kany wrote:> This code disables the ''Save'' button once clicked, but doesn''t seem to > send the form data. > <%= submit_tag ''Save'', :class => ''submit'', :onclick => > "document.getElementById(''save_button'').disabled=true;", :id => > "save_button" %> > > This code sends the form data and a record is created, but isn''t > disabled once clicked. A user can click this many times, creating a new > record each time. > <%= submit_tag ''Save'', :class => ''submit'', :onclick => > "document.getElementById(''save_button'').disabled=true;", :id => > "save_button" %> > > Anyone know of a way to fix the javascript to disable the ''Save'' button > and also send the form data when clicked once?I think you made a copy / paste mistake. I can''t find a character''s worth of difference between the two. Try again, or point me. Best regards, Bill -- 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.
When you write that onclick, don''t you have to also make it submit the form? Try this: <%= submit_tag ''Save'', :class => ''submit'', :onclick => "document.getElementById(''save_button'').disabled=true;document.forms["myform"].submit();", :id => "save_button" %> changing the id, obviously. -- 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.
Sorry about that. I meant to replace ":onclick" with ":onchange". bill walton wrote:> Hi Frank, > > On Wed, 2010-01-20 at 22:44 +0100, Frank Kany wrote: >> "document.getElementById(''save_button'').disabled=true;", :id => >> "save_button" %> >> >> Anyone know of a way to fix the javascript to disable the ''Save'' button >> and also send the form data when clicked once? > > I think you made a copy / paste mistake. I can''t find a character''s > worth of difference between the two. Try again, or point me. > > Best regards, > Bill-- 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.
I will give that a try. Thank you guys. Steve Klabnik wrote:> When you write that onclick, don''t you have to also make it submit the > form? Try this: > > <%= submit_tag ''Save'', :class => ''submit'', :onclick => > "document.getElementById(''save_button'').disabled=true;document.forms["myform"].submit();", > :id => > "save_button" %> > > changing the id, obviously.-- 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.
On Jan 20, 10:08 pm, Frank Kany <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I will give that a try. >Also look at submit_tag''s :disable_with option - no need to reinvent the wheel! Fred> Thank you guys. > > Steve Klabnik wrote: > > When you write that onclick, don''t you have to also make it submit the > > form? Try this: > > > <%= submit_tag ''Save'', :class => ''submit'', :onclick => > > "document.getElementById(''save_button'').disabled=true;document.forms["myfor m"].submit();", > > :id => > > "save_button" %> > > > changing the id, obviously. > > -- > Posted viahttp://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.