i have a form_tag with two button: <% form_tag "/controller/action" %> <% submit_tag ''send'' %> <% submit_tag ''check'', :onclick => "javascript:... %> <% end %> I would if I click on check-button, javascript is ONLY called and not the Action. And when i click the send-button the action is called. Can someone helps me. Thanks im Advance. -- Posted via http://www.ruby-forum.com/.
Hi U can try this Controller: def new if params[:save] @val = Product.new(params[:product]) @val.save @flash[:notice]="Supplier successfully created." end if params[:check] @users = Product.find(params[:id]) @users.update_attributes(params[:product]) @flash[:notice]="Supplier has been updated successfully." end end Rhtml <% form_tag :action=>new %> <% submit_tag ''send'' ,:name=>save%> <% submit_tag ''check'', :name=>check,:onclick => "javascript:... %> <% end %> Thanks Seenu On Fri, Oct 30, 2009 at 1:39 PM, Simoha Simoha < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > i have a form_tag with two button: > <% form_tag "/controller/action" %> > <% submit_tag ''send'' %> > <% submit_tag ''check'', :onclick => "javascript:... %> > <% end %> > I would if I click on check-button, javascript is ONLY called and not > the Action. And when i click the send-button the action is called. > > Can someone helps me. > > Thanks im Advance. > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
hi Seenu, thanks for replay. I think I have not correctly formulated my problem. I want, if I click the check button only the javascript function (check()) called . . <script type="text/javascript"> function scheck(){ alert("test"); } </script> <% form_tag :action=>new %> <% submit_tag ''send'' ,:name=>save%> <% submit_tag ''check'', :name=>check,:onclick => "check()" %> <% end %> when I click on ckeck-button: check() and action are called. But I want, if I click the check button ONLY the javascript function (check()) called. Sorry, I know my English is not good. but I hope you understand me..:) Tnaks im Advance -- Posted via http://www.ruby-forum.com/.
In order to create a JavaScript-only button, you have to use "button_to_function" helper instead of "submit_tag". See the following documentation. http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#M001757 Glen On Oct 30, 1:33 am, Simoha Simoha <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> hi Seenu, thanks for replay. > I think I have not correctly formulated my problem. > I want, if I click the check button only the javascript function > (check()) called > . > . > <script type="text/javascript"> > function scheck(){ > alert("test");} > > </script> > <% form_tag :action=>new %> > <% submit_tag ''send'' ,:name=>save%> > <% submit_tag ''check'', :name=>check,:onclick => "check()" %> > <% end %> > when I click on ckeck-button: check() and action are called. But I want, > if I click the check button ONLY the javascript function (check()) > called. > Sorry, I know my English is not good. but I hope you understand me..:) > > Tnaks im Advance > -- > Posted viahttp://www.ruby-forum.com/.
Glen, Thanks, that, what i search :) Glen wrote:> In order to create a JavaScript-only button, you have to use > "button_to_function" helper instead of "submit_tag". See the > following documentation. > > http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#M001757 > > Glen > > > > > On Oct 30, 1:33�am, Simoha Simoha <rails-mailing-l...@andreas-s.net>-- Posted via http://www.ruby-forum.com/.