Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
Gray out one radiobutton based on status of another

I want the "that" button to be disabled unless "this" is clicked.

But I'm getting a javascript error wherein it "cannot read the property of a null" when checking the "checked" quality of "this". Am I not referring to it the right way?

<asp:Content ID="Content2" runat="server">
        <div><asp:RadioButton ID="this" /></div>
        <div><asp:RadioButton ID="that" /></div>

 <script type="text/javascript">
    $(document).ready(function () 
    {
       if (document.getElementById("this").checked == false
        {
            document.getElementById("that").disabled = true;
        } 
        
    });
  </script>
</asp:Content>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The ids of asp.net are change on render. Get the rendered id by using the .ClientID if the control. Your code will be like:

 <script type="text/javascript">
    $(document).ready(function () 
    {
       if (document.getElementById("<%=this.ClientID%>").checked == false
        {
            document.getElementById(""<%=that.ClientID%>"").disabled = true;
        } 
        
    });
  </script>

If you see the rendered html of the page by right click on page and view the page source will understand the issue here.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda