Forum: Ruby on Rails radio_button_tag checked='checked'

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Chetan T. (Guest)
on 2009-06-01 17:37

I have 3 radio buttons,

<%= radio_button_tag('method', 'auto', checked = 'checked',
options = {:onclick => "'avsAutoWrapper');
Element.hide('avsCustomWrapper'); Element.hide('avsLocalWrapper');"})

<%= radio_button_tag('method', 'custom', checked = false,
options = {:onclick => "Element.hide('avsAutoWrapper');'avsCustomWrapper'); Element.hide('avsLocalWrapper');"})

<%= radio_button_tag('method', 'local', checked = false,
options = {:onclick => "Element.hide('avsAutoWrapper');

Every radio button has its respective text field.
I want radio button Auto to be checked default.

And these are their <div>'s

<div id="avsAutoWrapper">
<%= render(:partial => "a_b_auto", :object => @product_build) %>

<div id="avsCustomWrapper">
<%= render(:partial => "a_b_custom", :object => @Product_build) %>

<div id="avsLocalWrapper">
<%= render(:partial => "a_b_local", :object => @product_build) %>

Now when the application starts and the page containing this three radio
buttons display at the very first time,I can see all the three text
fields of all of these radio buttons,which I don't want.

Just the text field of respective radio button must be displayed.
But this is not happening..
I had also tried the following format of radio buttons

<%= radio_button_tag('method', 'local', checked = true,
options = {:onclick => "Element.hide('avsAutoWrapper');'avsCustomWrapper'); Element.hide('avsLocalWrapper');"})


<%= radio_button_tag('method', 'local', true,
options = {:onclick => "Element.hide('avsAutoWrapper');'avsCustomWrapper'); Element.hide('avsLocalWrapper');"})

but it wont work.

Please help me.


This topic is locked and can not be replied to.