form_tag wih two Button

View: New views
5 Messages — Rating Filter:   Alert me  

form_tag wih two Button

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: form_tag wih two Button

by srinivasan sakthivel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...> 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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: form_tag wih two Button

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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/.

--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: form_tag wih two Button

by Glenn-27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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...@...>
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/.
--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: form_tag wih two Button

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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...@...>

--
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---