Re: question about Form

jemminger
Thu, 21 Jun 2007 04:13:12 -0000

typically if you''re going to use more than one submit button inside a
form, then you can check to see which was clicked in two ways:

1.  name both buttons the same, and check which value is posted

 <input type=''submit'' name=''btnSubmit''
value=''submit one'' />
 <input type=''submit'' name=''btnSubmit''
value=''submit two'' />


if params[:btnSubmit] == "submit one"
  ... do this ...
else
  ... do that ...
end

2.  name the buttons differently, and see which posts a value

 <input type=''submit'' name=''btnSave''
value=''Save'' />
 <input type=''submit'' name=''btnCancel''
value=''Cancel'' />


if params[:btnSave]
  ... do this ...
elsif params[:btnCancel]
  ... do that ...
end

personally I tend to use method # 2


On Jun 20, 10:30 pm, "huang zhimin"
<flyer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> I have a case that a form has two submit button,
> one is edit button that only change the current div that can use
> form_remote_tag,
> the other is delete button that should refresh the whole page that can use
> form_tag.
>
> But I what use edit and delete button both in a form, how can I do that?
>
> --http://sourceforge.net/projects/mycodeline/