Just off the top of my head, but may work...

$(document).ready(function() {

     $('#offices_checkboxes').hide();

     $('input:radio[name=radioName]:checked').click(function() {
          $('#offices_checkboxes').show();
     });

     $('input:radio[name=radioName]:not(:checked)'.click(function() {
          $('#offices_checkboxes').hide();
     });

});

This code makes use of the name of the radio button group, as well.

hth,

Rick

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of mtuller
Sent: Monday, September 14, 2009 11:14 AM
To: jQuery (English)
Subject: [jQuery] Hide/Show based on radio button selected


I am trying to create a script that will display content based on if a
radio button is selected, and if the other is selected would hide the
content. Now, each of these radio buttons are part of a radio group,
so their names are the same. Most examples show input:radio
[...@name=item] Since I have 2 items that have the same name, I can't use
name, so I thought I would try id or value. It isn't working. If I add
only the show, whenever you select either radio button, it shows, and
if I add the hide code, it doesn't work at all.

Here is what I have right now.

        $(document).ready(function(){
                  $('#offices_checkboxes').hide();
                  $("input:rad...@value=1]").click(function() {
                          $("#offices_checkboxes").show();
                  });
                  $("input:rad...@value=0]").click(function() {
                          $("#offices_checkboxes").hide();
                  });

        });

Anybody have an idea of how I could get this to work?




Reply via email to