• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 58
  • Last Modified:

VS2012 / Javascript

This doesn't work and I don't know why?
    <script type="text/javascript">
        function GameDate() {
            if(document.getElementById('chk_AllGameDate.ClientID').checked)
            {
                document.getElementById('txt_GameDate.ClientID').disabled = 'false';
            }
            else
            {
                document.getElementById('txt_GameDate.ClientID').disabled = 'true';
            }
        }

    </script>
I want to enable a textbox when the checkbox is checked off!

I get this error when I click the Check Box:
0x800a138f - JavaScript runtime error: Unable to get property 'checked' of undefined or null reference
0
smithmrk
Asked:
smithmrk
1 Solution
 
Duy PhamFreelance IT ConsultantCommented:
I think it is because no control exists with such chk_AllGameDate.ClientID ID. Try to remove .ClientID (also in txt_GameDate.ClientID).

Are you developing an asp.net web app? If yes then you'd better use server tag <%= chk_AllGameDate.ClientID %> instead.
0
 
smithmrkAuthor Commented:
This Fixed my issue:

use server tag <%= chk_AllGameDate.ClientID %>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now