hiding an asp .net radio button list item with javascript

i have a radio button list that i have created and i want to hide on of the items. i use the javascript function

function UpdateLists()
        {
            var radiobutton = document.getElementById('ctl00_maincontent_empnolist_0')
           
                radiobutton.style.display = "none"
        }

however this only hides the radio button. i also have a label which is attached to the button by default but asp .net doesnt seem to assign it an id? so there is no way for me to find the label to hide it.

is there another solution to my problem? thanks in advance
rupurtAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

robotman757Commented:
Depending on where it is located you could put both the label and the button in the same <td> or <tr> tag and give that tag an id to hide or display. You could do it with a div tag as well
ZvonkoSystems architectCommented:
Either you have for every single radio button an unique name, what is strange, or you take only the first radio button returned by upper method.
Nevertheless, paut a div or a span around your buttons and labels and give that div one unique name.
Like this:

<div id="ctl00_maincontent_empnolist">
<labels and radios>
</div>


function UpdateLists(){
  var radiobutton = document.getElementById('ctl00_maincontent_empnolist')
  radiobutton.style.display = "none"
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
timkerCommented:
You said this is a .Net Radiobutton List so you can't create your own structure. However the RadioButtonList server control renders itself as a table like so:

<table id="RadioButtonList1" border="0" style="Z-INDEX: 101; LEFT: 256px; POSITION: absolute; TOP: 104px">
      <tr>
            <td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="1" /><label for="RadioButtonList1_0">1</label></td>
      </tr>
                 <tr>
            <td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="2" /><label for="RadioButtonList1_1">2</label></td>
      </tr
</table>

This is consistent so instead of hiding the radio button and the associated span, you want to hide the tr that contains them:
function UpdateLists()
        {
            var radiobutton = document.getElementById('ctl00_maincontent_empnolist_0')
            var tr = radiobutton.parentElement.parentElement;
            tr.style.display = "none"
        }
robotman757Commented:
oops I missed that .Net part!! I can't wait to get my copy of visual studio 2005...
ZvonkoSystems architectCommented:
If the radio buttons are all in a <tr> </tr>, then I can show you how to toggle that row without ID.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.