javascript invoke submit on parent window from child window

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:

PARENT WINDOW:
=============
<script language="JavaScript">
      myWindow = window.open("inc_verify_address.cfm", "addrWindow", 'toolbar=no,width=460,height=300,resizable=yes,scrollbars=yes');
      myWindow.focus();      
</script>

<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();">
</form>

CHILD WINDOW:
============
<script language="JavaScript">
function chg_addr()
{  
      window.opener.document.checkout.change_address_a.selected;
}
function prc_order()
{  
      window.opener.document.checkout.process_order_a.selected;
}
</script>

<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:
CHILD WINDOW:  
  window.opener.document.checkout.change_address_a.value = "true";

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

PARENT WINDOW:
function submit_this()
{
  document.checkout.submit_btn.submit();
}
<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">
</form>

I would appreciate comments on any approach that has worked for you in the past. Thanks!!!
sibylle_kennedyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alambresCommented:
window.opener.document.checkout.submit();
0
ZvonkoSystems architectCommented:
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="this.click();">

But both behaviours will onlu confuse the user.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
archrajanCommented:
<html>

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

function openPopup() {
  windowReference = window.open('popup.htm','windowName');
  if (!windowReference.opener)
    windowReference.opener = self;
}
//--></script>
</head>

<body>

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

</body>

</html>

And then in popup.htm:

<form>
<input type="button" value="Submit" onClick="opener.document.formName.submit()">
</form>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

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.