5
document.getElementById("ctrl").disabled = true;

this works in IE but does not works in mozila. What shoul I do?

1
  • 2
    What type of DOM element is ctrl? Can you post some HTML to go with your JavaScript? Commented Oct 20, 2010 at 11:28

3 Answers 3

20

Did you try:

document.getElementById("ctrl").setAttribute('disabled', true);
Sign up to request clarification or add additional context in comments.

2 Comments

Why does this work better than using .disabled = true?
This question is from 2010. Mozilla have implemented the direct .disabled since then.
3
<body>
    <input id="btnSubmit" type="button" value="submit" onclick="disabled(this);"/>
    <script>
        function disabled(ctrl) {
            ctrl.disabled = true;
        }
    </script>
</body>

Comments

0

It is hard to tell what the issue is that you are having. Does do anything when the code is executed? does it display an error? What version of did you test it with? And can you also provide the for the ctrl element?

One of the issue with IE and the getElementById method is that in some versions of the browser it will match on the id attribute of a tag as well as the name attribute (which does not follow the JavaScript spec). In Mozilla it is only matching using the id attribute.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.