views:

15

answers:

1

How will i have a form having more than one submit buttons..? And how will i know in the controller's action that which submit button is clicked..?

A: 

You can set various values of your submit buttons, so you will know which one was submitted. Like this:

<input type="submit" name="submit_btn" value="First submit" />
<input type="submit" name="submit_btn" value="Second submit" />

After that, check on the server-side when submit_btn equals "First submit" or "Second submit":

if params["submit_btn"] == "First submit"
    #Actions
else
    #Other actions
end
floatless
thnx for your help... BUT one thing is there that why it always get into the first condition..?
Jamal Abdul Nasir
Try to write `params["submit_btn"]` instead of `params[:submit_btn]`. Try also to debug your action by using `p params`, maybe.
floatless