# Obtaining a result from radio\_button\_tag

**URL:** <https://www.ruby-forum.com/t/obtaining-a-result-from-radio-button-tag/146277>\
**Category:** Rails\
**Created:** [August 19, 2008, 6:26pm UTC](https://www.ruby-forum.com/t/obtaining-a-result-from-radio-button-tag/146277 "2008-08-19T18:26:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecccb3/32.png) [@brads](https://www.ruby-forum.com/u/brads)\
**Post date:** [August 19, 2008, 6:26pm UTC](https://www.ruby-forum.com/t/obtaining-a-result-from-radio-button-tag/146277/1 "2008-08-19T18:26:50Z")

</div>

Im trying to figure out how to retrieve the selected radio button from a  
radio\_button\_tag.

I cant seem to obtain the selected member, and feed that into the DB.

I have 3 buttons which are defined in their own table RESULTS:  
(id, type)  
1, Pass  
2, Fail  
3, N/A

RESULTS belongs to OUTCOMES which basically is linked on result\_id

in my view:  
\<% @results.each do |r| %\>  
\<%= “#{r.resulttype}” -%\>  
%= radio\_button\_tag :result\_id, :result, true %\>  
\<% end %\>

which displays the buttons fine! not sure if its correct though

on clicking the save button \<% form\_tag ({:action =\> ‘verify’,  
:controller =\> ‘outcome’, :id =\> @testcase, :id1 =\> @testrun, :id2 =\>  
:result\_id}) do %\>

i would like the result id of the selected button to be passed as :id2

???

at the moment, i just seem to be generating long numbers when passing  
across.

{“id1”=\>“31”,  
“result\_id”=\>“2165464”,  
“id2”=\>“result\_id”,  
“commit”=\>“Save”,  
“id”=\>“1”}

i noticed the form seems to be grabbing result\_id as a value, is there  
any way i can override this so it uses result\_id as :id2 in the url?

thanks in advance!

---

<div class="post-metadata">

**Author:** ![brads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecccb3/32.png) [@brads](https://www.ruby-forum.com/u/brads)\
**Post date:** [August 20, 2008, 11:23am UTC](https://www.ruby-forum.com/t/obtaining-a-result-from-radio-button-tag/146277/2 "2008-08-20T11:23:16Z")

</div>

radio\_button\_tag(name, value, checked = false, options = {})

Change the name to id2 if you want value to be returned in id2 when  
the form is submitted. What is the value of :result\_id? It seems to  
be a class id value. Are you sure that is what you want to assign to  
that radio button (maybe you mistyped r.result\_id ?)

On Aug 19, 9:26 pm, Brad S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
