# button\_to\_function with image?

**URL:** <https://discuss.rubyonrails.org/t/button-to-function-with-image/13166>\
**Category:** rubyonrails-talk\
**Created:** [May 19, 2007, 6:12pm UTC](https://discuss.rubyonrails.org/t/button-to-function-with-image/13166 "2007-05-19T18:12:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alain\_Ravet](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@Alain\_Ravet](https://discuss.rubyonrails.org/u/Alain_Ravet)\
**Post date:** [May 19, 2007, 6:12pm UTC](https://discuss.rubyonrails.org/t/button-to-function-with-image/13166/1 "2007-05-19T18:12:10Z")

</div>

Mike,

&nbsp;&nbsp;&nbsp;\> does button\_to\_function allow the use of an image? I tried it in place &nbsp;&nbsp;&nbsp;\> of the text with "image\_tag" and it doesn't work. Maybe some form of &nbsp;&nbsp;&nbsp;\> button\_to?

I couldn't find a way to pass an image as parameter, but you can fabricate it yourself.

&nbsp;&nbsp;\<%= content\_tag(:button, image\_tag("ok.png")+"Submit", :type =\> "submit") %\>

A good candidate for a helper.

Alain Ravet

---

<div class="post-metadata">

**Author:** ![Alain\_Ravet](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@Alain\_Ravet](https://discuss.rubyonrails.org/u/Alain_Ravet)\
**Post date:** [May 20, 2007, 4:46pm UTC](https://discuss.rubyonrails.org/t/button-to-function-with-image/13166/2 "2007-05-20T16:46:29Z")

</div>

Mike,

&nbsp;&nbsp;&nbsp;\> But here's what I did: &nbsp;&nbsp;&nbsp;\> \<%= content\_tag(:button, image\_tag("btn\_send.gif"), :type =\> "submit", :onclick =\> "closeiframe();") %\> &nbsp;&nbsp;&nbsp;\> So when I do this, it puts a button-box around "image\_tag".

Yep. That's what you're looking for, arent't you? see: &nbsp;&nbsp;&nbsp;&nbsp;[Particletree » Rediscovering the Button Element](http://particletree.com/features/rediscovering-the-button-element/)

Note: if you don't need text in the button, there is : &nbsp;&nbsp;&nbsp;image\_submit\_tag &nbsp;&nbsp;&nbsp;[http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M000613](http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M000613)

Alain Ravet
