# Parameter in a image\_submit\_tag?

**URL:** <https://www.ruby-forum.com/t/parameter-in-a-image-submit-tag/117307>\
**Category:** Rails\
**Created:** [October 15, 2007, 9:17pm UTC](https://www.ruby-forum.com/t/parameter-in-a-image-submit-tag/117307 "2007-10-15T21:17:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 15, 2007, 9:17pm UTC](https://www.ruby-forum.com/t/parameter-in-a-image-submit-tag/117307/1 "2007-10-15T21:17:14Z")

</div>

You can send a parameter in a image\_submit\_tag?

I have two buttons on a form and I do not know how to differentiate  
which has been pressed.

\<=% Image\_submit\_tag ("…/ images / incluir.gif “: op =\>” addImage “)%\>  
\<=% Image\_submit\_tag (”…/ images / eliminar.gif “: op =\>” delImage ")%\>

Thank you

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 16, 2007, 1:14pm UTC](https://www.ruby-forum.com/t/parameter-in-a-image-submit-tag/117307/2 "2007-10-16T13:14:27Z")

</div>

Thank you

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 16, 2007, 3:38am UTC](https://www.ruby-forum.com/t/parameter-in-a-image-submit-tag/117307/3 "2007-10-16T03:38:45Z")

</div>

On Oct 15, 3:17 pm, “Ramón Castro” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You can send a parameter in a image\_submit\_tag?
> 
> I have two buttons on a form and I do not know how to differentiate  
> which has been pressed.
> 
> \<=% Image\_submit\_tag ("…/ images / incluir.gif “: op =\>” addImage “)%\>  
> \<=% Image\_submit\_tag (”…/ images / eliminar.gif “: op =\>” delImage ")%\>

Ramon – I just had a similar case with submit\_tag (which creates a  
submit button and calls the action associated with the form). I  
solved the problem by adding a :name parameter as one of the optional  
parameters, then testing for in in the submit action associated with  
the form. (I am not sure if :name is special, I was just copying an  
example I found :-). , for example

\<=% Image\_submit\_tag ("…/ images / eliminar.gif ", :name =\>  
“del\_image”) %\>

then in the controller, if your form action was called “manage\_image”,  
you can test for the presence of the specific name value in the params  
hash, like so:

def manage\_image  
if params[‘del\_image’] ##  
… code to delete the image …  
else  
… code to add the image …  
end  
end

Here’s the link I found with a more complete description of the  
solution:  
[http://www.railsdiary.com/diary/two\_submit\_buttons](http://www.railsdiary.com/diary/two_submit_buttons)

Tom

I wish I had the

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [May 19, 2009, 9:48am UTC](https://www.ruby-forum.com/t/parameter-in-a-image-submit-tag/117307/4 "2009-05-19T09:48:14Z")

</div>

DavicÃ­n … wrote:

> Thank you  
> You have to check  
> if params[‘del\_image.x’] ##  
> … code to delete the image …  
> else  
> … code to add the image …  
> end
