Javascript disable button in parent form

Posted on 2007-09-27
Last Modified: 2012-06-21
I have a parent window tha opens a child window. I would like to disable the button from the parent window only if child form is submitted successfully.
Question by:Cali123
    LVL 23

    Accepted Solution

    If you have a button like this in the parent window:

    <input type="button" id="someId"/>

    Then you can disable it from the child window like this:

    window.opener.document.getElementById('someId').disabled = true;

    Only your server side code knows if the form was submitted successfully, so on the child window have your server side code write the disable button script when it is rendering the child window after a successful form submission...
    LVL 3

    Expert Comment

    I guess it all means on what you mean by "successful submit" of  the child window.

    Have the child track if the page was submitted successfully. Have some hidden flag to identify this.
    (I'm assuming that the child page comes back after a submit.)

    Then based on that, set the button state of the opener as instructed above.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now