How to to hide a radio button option along with it's label?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Boyce
    New Member
    • Oct 2010
    • 3

    How to to hide a radio button option along with it's label?

    Hi Everyone.
    It may be simple, I dunno... I never had to do this before and for the life of me I can't find anything on the net so far.
    I have a radio button group (which I'll post after this message). I have to hide a radio button option with it's label. ie: in the example below, I want to hide option id=rbIntrusionD etectC along with the CEP label. Is this possible using javascript?
    I was able to hide the actual radio button, but not the corresponding label.
    Your help is much appreciated.
    Thanks.
    D.

    Code:
    <div id="rbIntrusionDetect_div"
      class="showControl"><input type="radio" name="ui.rbIntrusionDetect.value" id="rbIntrusionDetectY" value="Y"/><label for="rbIntrusionDetectY">Yes</label>
    <input type="radio" name="ui.rbIntrusionDetect.value" id="rbIntrusionDetectN" value="N"/><label for="rbIntrusionDetectN">No</label>
    <input type="radio" name="ui.rbIntrusionDetect.value" id="rbIntrusionDetectC" value="C"/><label for="rbIntrusionDetectC">CEP</label>
    
    </div>
    Last edited by acoder; Jan 14 '12, 06:08 PM.
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    How are you hiding the radio button? You should be able to apply the same method to your label whether it be javascript or jquery.

    Comment

    • Dan Boyce
      New Member
      • Oct 2010
      • 3

      #3
      Here's the code I'm using to hide the button, but it doesn't hide the label of the button.

      document.getEle mentById ('rbIOSFirewall C').style.visib ility='hidden';

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        The label is a separate element so you would also need to hide it.

        Add an id to your label and hide it the same way.

        Make note that using visibility='hid den'; hides the element but the element still occupies the space it was in.

        If you need to remove the element from view and spacing you can use style.display=' none';.

        Comment

        • Dan Boyce
          New Member
          • Oct 2010
          • 3

          #5
          Thanks JKing, but I don't think that's going to work for me. The radio tags are generated with struts (which I'm very weak in.... it creates the radio tags with the <s:radio tags in struts) I've been looking around the net for ways to insert that ID to the label portion of the radio button using struts but I can't the method to do this. I'll have to do a bit more digging around to see if there's some bastardized way of doing this since it's just for the 1 field.

          Thanks again for your help and suggestion.
          Cheers.

          Comment

          • candidjava2
            New Member
            • Jan 2012
            • 3

            #6
            I think you failed to add xml files and tld files file here is the better way to resolve your problem refer this site http://candidjava.com/struts-tutorail

            Comment

            Working...