cathy n. wrote in post #1027986:
> I am new to rails and so have a very basic question. I have defined a
> set of radio buttons in _form.html like this:
>
> <%= radio_button_tag(:colour, "Blue") %>
> <%= label_tag(:colour_B, "Blue") %>
>
> Now I want to read the value of the radio button. Eg: if the user chose
> "Blue", then I want to display the user's name in a table under the
> column Blue. I already defined the table in index.html and I have a
> model called usertable that I previously defined on the command line
> using:
Keep in mind that radio button need to be defined in a radio button
group. Create the group by using the same value for the name attribute
of each radio button in the group:
Example:
radio_button_tag 'gender', 'male'
# => <input id="gender_male" name="gender" type="radio" value="male" />
radio_button_tag 'gender', 'female'
# => <input id="gender_female" name="gender" type="radio" value="female"
/>
Notice the name of the two radio button are both "gender".
The result will appear on the params like:
{"utf8"=>"✓",
"authenticity_token"=>"joHm5S13RnrNzaLv7t7HKU48SD6h6e5MRbwYwNU6nJA=",
"gender"=>"female", "submit"=>"Create"}
params[:gender]
>> female
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.