# Radio Button Question

**URL:** <https://www.ruby-forum.com/t/radio-button-question/107452>\
**Category:** Rails\
**Created:** [June 21, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/radio-button-question/107452 "2007-06-21T22:48:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [June 21, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/radio-button-question/107452/1 "2007-06-21T22:48:42Z")

</div>

Hi all,

I’m a new Ruby on Rails user, and I’m trying to make a page with  
several groups of 3 radio buttons. The user chooses one button from  
each group, then clicks the save button, where each selection is  
stored in the database. My question is how I can know which button was  
selected - is there a method like get\_checked\_button, or do I have to  
cycle through each group and see which of the three is checked? If the  
latter is the case, how would I do that?

Thanks!

-Kevin

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [June 25, 2007, 11:01am UTC](https://www.ruby-forum.com/t/radio-button-question/107452/2 "2007-06-25T11:01:58Z")

</div>

Hi Kevin,

actually I do this with javascript and a snippet of ruby  
may somebody know a better way to do this.

regards

Rafael

* * *

case params[:apply\_as]  
when “spontanous”  
@apply\_as\_spontanous = ‘checked’  
when “specific”  
@apply\_as\_specific = ‘checked’  
else  
@apply\_as\_specific = ‘checked’  
end

* * *

\<input type=“radio” name=“apply\_as” id=“apply\_as” value=“spontanous” \<  
%= “#{@apply\_as\_spontanous}” %\> /\> Spontanbewerbung  
\<input type=“radio” name=“apply\_as” id=“apply\_as” value=“specific” \<  
%= “#{@apply\_as\_specific}” %\> /\> Bewerbung auf Offene Vakanz
