# Radio buttons and :onchange

**URL:** <https://www.ruby-forum.com/t/radio-buttons-and-onchange/187325>\
**Category:** Rails\
**Created:** [April 21, 2010, 6:12pm UTC](https://www.ruby-forum.com/t/radio-buttons-and-onchange/187325 "2010-04-21T18:12:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [April 21, 2010, 6:12pm UTC](https://www.ruby-forum.com/t/radio-buttons-and-onchange/187325/1 "2010-04-21T18:12:27Z")

</div>

Hi all,

I have three radio buttons that when clicked are supposed to show a  
particular div and hide other divs, pretty straight forward. But what I  
have noticed is that while the code works perfectly in Chrome and  
Firefox it breaks down in IE 7 & 8. Here is the code:

\<%= radio\_button\_tag( :synch, :div\_1, @account.div\_1 == true ? true :  
false, :onchange =\> ‘new Effect.Fade(‘div2\_check’); new  
Effect.Appear(‘div1\_check’);’ ) %\>

\<%= radio\_button\_tag( :synch, :div\_2, @account.div\_2 == true ? true :  
false, :onchange =\> ‘new Effect.Fade(‘div1\_check’); new  
Effect.Appear(‘div2\_check’);’ ) %\>

\<%= radio\_button\_tag( :synch, :none, (@account.div\_1 == false and  
@account.div\_2 == false) ? true : false, :onchange =\> ‘new  
Effect.Fade(‘div1\_check’); new Effect.Fade(‘div2\_check’);’ ) %\>

 display:none;\<% end %\>border: 1px solid black;"\> ....

 display:none;\<% end %\>border: 1px solid black;"\> ...

When the page loads and I click on one of the radio buttons it’s almost  
as if the first click isn’t “heard”, and when I click a different radio  
button a div is shown but not the div that I clicked, instead the  
previous div is show from the “unheard” click.

Really I’m just wondering if anybody has encountered a similar problem  
and how they fixed it if they have. I have been looking at mis-matched  
tags with no luck. IE is giving me a JavaScript error at the bottom, but  
I am a little suspicious of this just because all other browsers fail to  
give a similar error and work as designed.

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [April 21, 2010, 6:45pm UTC](https://www.ruby-forum.com/t/radio-buttons-and-onchange/187325/2 "2010-04-21T18:45:46Z")

</div>

On 21 April 2010 17:12, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> …  
> previous div is show from the “unheard” click.
> 
> Really I’m just wondering if anybody has encountered a similar problem  
> and how they fixed it if they have. I have been looking at mis-matched  
> tags with no luck. IE is giving me a JavaScript error at the bottom, but  
> I am a little suspicious of this just because all other browsers fail to  
> give a similar error and work as designed.

Have you checked the html syntax by copying the full html of the page  
(View, Page source or similar in browser) and pasting into the w3c  
html validator (google it if necessary). Often differences between  
browsers are due to them interpreting invalid html differently. Not  
necessarily in this case of course but worth checking.

Colin

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [April 21, 2010, 7:33pm UTC](https://www.ruby-forum.com/t/radio-buttons-and-onchange/187325/3 "2010-04-21T19:33:17Z")

</div>

Colin L. wrote:

> On 21 April 2010 17:12, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > …  
> > previous div is show from the “unheard” click.
> > 
> > Really I’m just wondering if anybody has encountered a similar problem  
> > and how they fixed it if they have. I have been looking at mis-matched  
> > tags with no luck. IE is giving me a JavaScript error at the bottom, but  
> > I am a little suspicious of this just because all other browsers fail to  
> > give a similar error and work as designed.
> 
> Have you checked the html syntax by copying the full html of the page  
> (View, Page source or similar in browser) and pasting into the w3c  
> html validator (google it if necessary). Often differences between  
> browsers are due to them interpreting invalid html differently. Not  
> necessarily in this case of course but worth checking.
> 
> Colin

I have not done that yet, but will give it a try. Thanks,

-S
