Forum: Ruby on Rails Set Default Radio Button Value (html)

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.
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2009-03-08 03:57
(Received via mailing list)
Is there a way to set the default value of a radio button that is
coded in html with the value from an object?  I am trying to set up an
edit view for this object and am using submit_to_remote, so I cannot
use the rails radio button helper.  These are my radio buttons:

<input id="personal_block_option" type="radio" name="event
[block_avail]" value="true" checked="checked">
      <input id="personal_block_option" type="radio" name="event
[block_avail]" value="false">

I have an object: @object, is there any way to set the checked to the
@object.block_avail value?
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 Dave L (Guest)
on 2009-03-08 21:19
(Received via mailing list)
I think I got it figured out, I ended up writing a small javascript
function that finds the radio button by a unique id and sets its value
accordingly:

  $(RadioId).checked = true;
This topic is locked and can not be replied to.