# How to use options in radio botton

**URL:** <https://www.ruby-forum.com/t/how-to-use-options-in-radio-botton/114532>\
**Category:** Rails\
**Created:** [September 14, 2007, 8:17am UTC](https://www.ruby-forum.com/t/how-to-use-options-in-radio-botton/114532 "2007-09-14T08:17:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![selva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@selva](https://www.ruby-forum.com/u/selva)\
**Post date:** [September 14, 2007, 8:17am UTC](https://www.ruby-forum.com/t/how-to-use-options-in-radio-botton/114532/1 "2007-09-14T08:17:30Z")

</div>

Hi I am using radio botton,I am struggling to use options…following is  
my code…

\<%=  
radio\_button(‘community’,‘default’,0,options={:checked,:onClick=\>“javascript:set\_default(this);”})%\>

If i am using without checked option its working fine.If i use that its  
throwing error…

Please help me

---

<div class="post-metadata">

**Author:** ![selva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@selva](https://www.ruby-forum.com/u/selva)\
**Post date:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/how-to-use-options-in-radio-botton/114532/2 "2007-09-17T13:25:05Z")

</div>

You don’t need the “options=”. That is just in the method definition to  
let you know that the final argument is defaulted to an empty hash.

radio\_button(‘community’,‘default’,0,{:checked,:onClick=\>“javascript:set\_default(this);”})

Selvaraj S. wrote:

> 

–  
Sincerely,

William P.

---

<div class="post-metadata">

**Author:** ![selva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@selva](https://www.ruby-forum.com/u/selva)\
**Post date:** [September 25, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/how-to-use-options-in-radio-botton/114532/3 "2007-09-25T23:04:58Z")

</div>

One more thing I noticed. You need to supply a value for the :checked  
key like :checked =\> true

radio\_button(‘community’,‘default’,0,{:checked =\> true,:onClick =\>  
“javascript:set\_default(this);”})

William P. wrote:

> > my code…

–  
Sincerely,

William P.
