# How to show div with radio button onclick

**URL:** <https://www.ruby-forum.com/t/how-to-show-div-with-radio-button-onclick/160503>\
**Category:** Rails\
**Created:** [February 17, 2009, 5:47am UTC](https://www.ruby-forum.com/t/how-to-show-div-with-radio-button-onclick/160503 "2009-02-17T05:47:01Z")\
**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:** [February 17, 2009, 5:47am UTC](https://www.ruby-forum.com/t/how-to-show-div-with-radio-button-onclick/160503/1 "2009-02-17T05:47:01Z")

</div>

I am trying to get a div to show when a radio button is clicked but  
the problem is that the div is dynamically named. I am using the  
normal html for a radio button:

Because observe field does not work well with radio buttons. I have  
tried adding an onclick with the div id:

But the #{@appt\_to\_edit.id} does not get rendered and I have had a lot  
trouble figuring out how to do this. I think I need to use some sort  
of inline RJS? Im not sure, does anyone have any ideas?

---

<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:** [February 17, 2009, 10:22am UTC](https://www.ruby-forum.com/t/how-to-show-div-with-radio-button-onclick/160503/2 "2009-02-17T10:22:53Z")

</div>

').show()"\>

this should do it. You are inside HTML code and not inside a ruby  
string, so the #{} syntax won’t work. Instead you have to use the Erb  
sequence \<%= %\>
