javascript invoke submit on parent window from child window

Posted on 2004-11-29
Last Modified: 2007-12-19
I have a parent window that contains multiple submit buttons, depending on what option the user chooses (i.e. change address; process order; save as quote. If certain conditions are met, I need to pop up a new child window with some further instructions. After reading the instructions, the user has to choose to either "change address" or "process order", or just close the popup. Based on which button the user chooses in the child window, I need to automatically submit the corresponding button on the parent window.

Here's what I've got so far:

<script language="JavaScript">
      myWindow ="inc_verify_address.cfm", "addrWindow", 'toolbar=no,width=460,height=300,resizable=yes,scrollbars=yes');

<form name="checkout" action="act_parent.cfm" method="POST">
  <input type="submit" name="change_address_a" value="change" onselect="submit();"><br>
  <input type="submit" name="process_order_a" value="order" onselect="submit();">

<script language="JavaScript">
function chg_addr()
function prc_order()

<input type="button" name="change_address" value="change" onclick="chg_addr();window.close();">
<input type="button" name="process_order" value="process" onclick="prc_order();window.close();">

The child window is closed, but the form is not submitted on the parent window.

Alternately, I have successfully set a value for an input field in the parent window, from the child window, with this syntax:
  window.opener.document.checkout.change_address_a.value = "true";

However, the onchange event does not seem to be working; the form is not submitted.

function submit_this()
<form name="checkout" action="act_parent.cfm" method="POST">
  <input type="text" name="change_address_a" value="" onchange="submit_this();">
  <input type="submit" name="submit_btn" value="submit">

I would appreciate comments on any approach that has worked for you in the past. Thanks!!!
Question by:sibylle_kennedy
    LVL 5

    Expert Comment

    LVL 63

    Accepted Solution

    Remove this attribute from the submit buttons:  onselect="submit();"
    The function submit is not defined.
    Also you need not to submit the form explicitely; it will be submitted implicite on submit button click.
    If you like to submit the form on button select, then either call the form submit method like this:
    <input type="submit" name="process_order_a" value="order" onfocus="this.form.submit();">

    Or call the click() method of the submit button when the button is selected:
    <input type="submit" name="process_order_a" value="order" onfocus=";">

    But both behaviours will onlu confuse the user.
    LVL 25

    Expert Comment


    <script language="JavaScript"><!--
    var windowReference;

    function openPopup() {
      windowReference ='popup.htm','windowName');
      if (!windowReference.opener)
        windowReference.opener = self;


    <form name="formName" onSubmit="alert('submit triggered')">



    And then in popup.htm:

    <input type="button" value="Submit" onClick="opener.document.formName.submit()">

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    737 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

    21 Experts available now in Live!

    Get 1:1 Help Now