Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!