# Set Default Radio Button Value (html)

**URL:** <https://www.ruby-forum.com/t/set-default-radio-button-value-html/162291>\
**Category:** Rails\
**Created:** [March 8, 2009, 3:57am UTC](https://www.ruby-forum.com/t/set-default-radio-button-value-html/162291 "2009-03-08T03:57:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [March 8, 2009, 3:57am UTC](https://www.ruby-forum.com/t/set-default-radio-button-value-html/162291/1 "2009-03-08T03:57:18Z")

</div>

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:

I have an object: @object, is there any way to set the checked to the  
@object.block\_avail value?

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [March 8, 2009, 9:19pm UTC](https://www.ruby-forum.com/t/set-default-radio-button-value-html/162291/2 "2009-03-08T21:19:45Z")

</div>

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;
