Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda