Forum: Ruby on Rails radio_button_tag checked='checked'

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


I have 3 radio buttons,

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

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

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

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>

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

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



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');
Element.show('avsCustomWrapper'); Element.hide('avsLocalWrapper');"})
%>Custom


and

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

but it wont work.


Please help me.

Thanks

Chetan.
This topic is locked and can not be replied to.