# Naughty radio\_buttons

**URL:** <https://www.ruby-forum.com/t/naughty-radio-buttons/83968>\
**Category:** Rails\
**Created:** [January 31, 2007, 4:50am UTC](https://www.ruby-forum.com/t/naughty-radio-buttons/83968 "2007-01-31T04:50:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [January 31, 2007, 4:50am UTC](https://www.ruby-forum.com/t/naughty-radio-buttons/83968/1 "2007-01-31T04:50:05Z")

</div>

hi:

I have 2 radio buttons that are just interface elements:  
radio\_button\_tag. I don’t really care about their method or object, I  
just want to fire some login on the page based on whether or not they’re  
clicked. Problem is, they’re not behaving together, meaning I can have  
them both be checked at the same time, which is a no-no. Is this a  
limitation of radio\_button\_tag becuase it’s not hooked up to a form.  
Here’s my radio button code in my view:

\<%= radio\_button\_tag (’’, 0, checked = false, options = {:onclick =\>  
“”}) %\>  
\<%= radio\_button\_tag (’’, 1, checked = false, options = {:onclick =\>  
“”}) %\>

What am I doing wrong? I just want them to perform as normal radio  
buttons and then use their “onclick” option to fire off some javascript.

Thanks very much in advance for your help!

Mike

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [January 31, 2007, 5:53am UTC](https://www.ruby-forum.com/t/naughty-radio-buttons/83968/2 "2007-01-31T05:53:54Z")

</div>

Mike D. wrote:

> hi:
> 
> I have 2 radio buttons that are just interface elements:  
> radio\_button\_tag. I don’t really care about their method or object, I  
> just want to fire some login on the page based on whether or not they’re  
> clicked. Problem is, they’re not behaving together, meaning I can have  
> them both be checked at the same time, which is a no-no. Is this a  
> limitation of radio\_button\_tag becuase it’s not hooked up to a form.  
> Here’s my radio button code in my view:
> 
> \<%= radio\_button\_tag (’’, 0, checked = false, options = {:onclick =\>  
> “”}) %\>  
> \<%= radio\_button\_tag (’’, 1, checked = false, options = {:onclick =\>  
> “”}) %\>
> 
> What am I doing wrong? I just want them to perform as normal radio  
> buttons and then use their “onclick” option to fire off some javascript.
> 
> Thanks very much in advance for your help!
> 
> Mike

The name of both radio buttons is ‘’, an empty string. The browser will  
only allow one selection based on the radio buttons name. I think the  
browser is getting confused by the lack of a name.

So give that first parameter a real value, and it should work fine.

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [January 31, 2007, 5:08pm UTC](https://www.ruby-forum.com/t/naughty-radio-buttons/83968/3 "2007-01-31T17:08:51Z")

</div>

Alex W. wrote:

> Mike D. wrote:
> 
> > hi:
> > 
> > I have 2 radio buttons that are just interface elements:  
> > radio\_button\_tag. I don’t really care about their method or object, I  
> > just want to fire some login on the page based on whether or not they’re  
> > clicked. Problem is, they’re not behaving together, meaning I can have  
> > them both be checked at the same time, which is a no-no. Is this a  
> > limitation of radio\_button\_tag becuase it’s not hooked up to a form.  
> > Here’s my radio button code in my view:

> > What am I doing wrong? I just want them to perform as normal radio  
> > buttons and then use their “onclick” option to fire off some javascript.
> > 
> > Thanks very much in advance for your help!
> > 
> > Mike
> 
> The name of both radio buttons is ‘’, an empty string. The browser will  
> only allow one selection based on the radio buttons name. I think the  
> browser is getting confused by the lack of a name.
> 
> So give that first parameter a real value, and it should work fine.

Hi Alex:

Thanks so much for your reply. I had it this way:

> > \<%= radio\_button\_tag (‘duedate’, 0, checked = false, options = {:onclick =\>  
> > “”}) %\>  
> > \<%= radio\_button\_tag (‘noduedate’, 1, checked = false, options = {:onclick =\>  
> > “”}) %\>

And it still didn’t work. but that’s because there aren’t any values  
for these two things, no methods, because they’re really not supposed to  
be hooked up to anything.

Any further ideas?

Thanks again!

Mike

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [January 31, 2007, 5:32pm UTC](https://www.ruby-forum.com/t/naughty-radio-buttons/83968/4 "2007-01-31T17:32:38Z")

</div>

Mike D. wrote:

> Alex W. wrote:
> 
> > Mike D. wrote:
> > 
> > > hi:
> > > 
> > > I have 2 radio buttons that are just interface elements:

> > > \<%= radio\_button\_tag (‘duedate’, 0, checked = false, options = {:onclick =\>  
> > > “”}) %\>  
> > > \<%= radio\_button\_tag (‘noduedate’, 1, checked = false, options = {:onclick =\>  
> > > “”}) %\>
> 
> And it still didn’t work. but that’s because there aren’t any values  
> for these two things, no methods, because they’re really not supposed to  
> be hooked up to anything.

Pretty sure that needs to be

\<%= radio\_button\_tag (‘duedate’, 0, checked = false, options = {:onclick  
=\> “”}) %\>

\<%= radio\_button\_tag (‘duedate’, 1, checked = false, options = {:onclick  
=\>""}) %\>

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [January 31, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/naughty-radio-buttons/83968/5 "2007-01-31T19:52:49Z")

</div>

Benjamin Ritcey wrote:

> Mike D. wrote:
> 
> > Alex W. wrote:
> > 
> > > Mike D. wrote:
> > > 
> > > > hi:
> > > > 
> > > > I have 2 radio buttons that are just interface elements:
> 
> > > > \<%= radio\_button\_tag (‘duedate’, 0, checked = false, options = {:onclick =\>  
> > > > “”}) %\>  
> > > > \<%= radio\_button\_tag (‘noduedate’, 1, checked = false, options = {:onclick =\>  
> > > > “”}) %\>
> > 
> > And it still didn’t work. but that’s because there aren’t any values  
> > for these two things, no methods, because they’re really not supposed to  
> > be hooked up to anything.
> 
> Pretty sure that needs to be
> 
> \<%= radio\_button\_tag (‘duedate’, 0, checked = false, options = {:onclick  
> =\> “”}) %\>

Hi:

yes, I’ve tried that and that still doesn’t work. Do these need to be in  
a form\_for or something like that?

Thanks again for any help you can provide!

Mike

> \<%= radio\_button\_tag (‘duedate’, 1, checked = false, options = {:onclick  
> =\>""}) %\>
