# \<button type="button"

**URL:** <https://discuss.rubyonrails.org/t/button-type-button/52099>\
**Category:** rubyonrails-talk\
**Created:** [June 4, 2010, 4:40am UTC](https://discuss.rubyonrails.org/t/button-type-button/52099 "2010-06-04T04:40:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [June 4, 2010, 4:40am UTC](https://discuss.rubyonrails.org/t/button-type-button/52099/1 "2010-06-04T04:40:16Z")

</div>

Hi &nbsp;&nbsp;&nbsp;I would like to construct a button like \<button type="button" onclick="javascript:test();" class="form-button2 fixed3"\>\<span\>Add \</span\>\</button\>

And I used the helper button\_to\_remote for this like

\<%= button\_to\_remote("\<span\>Add\</span\>", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ :url =\> some\_url(@id), &nbsp;&nbsp;&nbsp;&nbsp;:condition =\> "check\_valid()", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:with=\> "'ids='+user\_ids"}, &nbsp;&nbsp;&nbsp;&nbsp;{:class =\> "form-button2 fixed3"} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) %\>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I get the functionality correctly But it produces html like

\<input type"button" class="form-button2 fixed3"......../\> So ignoring css style

&nbsp;&nbsp;&nbsp;Please tell me which helper to use to get html like \<button type="button"...

Thanks in advance Tom

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [June 4, 2010, 11:59am UTC](https://discuss.rubyonrails.org/t/button-type-button/52099/2 "2010-06-04T11:59:59Z")

</div>

Hi &nbsp;&nbsp;&nbsp;Did not get ny reply. Please help. It is urgent

Tom

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [June 4, 2010, 12:30pm UTC](https://discuss.rubyonrails.org/t/button-type-button/52099/3 "2010-06-04T12:30:11Z")

</div>

Tom Mac wrote:

> Hi &nbsp;&nbsp;&nbsp;Did not get ny reply. Please help. It is urgent
> 
> Tom

Bumping after 5 hours doesn't make people want to help you.

Best,

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [June 7, 2010, 3:44am UTC](https://discuss.rubyonrails.org/t/button-type-button/52099/4 "2010-06-07T03:44:20Z")

</div>

Hi &nbsp;&nbsp;&nbsp;You are right. But still the problem. Please help if possible

Tom

---

<div class="post-metadata">

**Author:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [June 7, 2010, 8:47am UTC](https://discuss.rubyonrails.org/t/button-type-button/52099/5 "2010-06-07T08:47:58Z")

</div>

I don't think there is a method you'll be able to use to generate a \<button\> tag. There seem to be some compatibility issues with that tag. I guess you have your reasons to be using \<button\> instead of \<input type="button"\>. In any case, since the call to button\_to\_remote will just generate a string that will be passed back to the browser as html maybe you can just hack something with a regex and manipulate the result of button\_to\_remote to replace the initial '\<input' with '\<button'. I don't know if that will work but it could be worth a try?

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [June 7, 2010, 8:54am UTC](https://discuss.rubyonrails.org/t/button-type-button/52099/6 "2010-06-07T08:54:19Z")

</div>

You can always just put the raw html in yourself.

Colin

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [June 7, 2010, 9:00am UTC](https://discuss.rubyonrails.org/t/button-type-button/52099/7 "2010-06-07T09:00:13Z")

</div>

Hi &nbsp;&nbsp;&nbsp;Finally I solved like

&nbsp;&nbsp;\<button type="button" onclick="if (check\_valid()) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new Ajax.Request('\<%= some\_url(@id) %\>', { asynchronous:true, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evalScripts:true, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parameters:'ids='+user\_ids &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});};" class="form-button2 fixed3"\>\<span\>Add \</span\>\</button\>

And may I conclude that there is no helper which gives exact raw html like \<button type="button

Tom
