Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Submitting a form with "opener" as the target

Posted on 2002-05-16
4
Medium Priority
?
580 Views
Last Modified: 2008-02-01
I have an HTML page that displays data. On that form there's a button that opens another HTML (using window.open) that allows the user to change preferences.

The preferences HTML looks like a regular application popup. When the user presses OK, I have a very complicated form, which I want to submit.

My problem - I want the target to be the "main" page - the one that displays the data. I tried using the target property of the form in the popup page, but it doesn't work:
- I can't use "_parent" since the parent of a window created using window.open() is the window itself.
- The same goes for "_top".
- There's no target="_opener" (Using opened I can get from the popup page to the main page).
- I tried having the main page as a frame with a name. Still, having the target of the popup page point to that frame doesn't work.

One final word: I need something to work with IE5+, NN6. Thanks.
0
Comment
Question by:barakori
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 30

Expert Comment

by:third
ID: 7013361
a workaround on this is to create same form from the opener window. upon the click of "ok" button the values of the popup form will be copied to the opener form then submit then close the popup window.


In the main page:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
myPopup = '';

function openPopup(url) {
    myPopup = window.open(url,'popupWindow','width=640,height=480');
    if (!myPopup.opener)
         myPopup.opener = self;
}
//--></SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="BUTTON" VALUE="Open Popup" onClick="openPopup('popupPage.html')">
</FORM>

<FORM NAME="hiddenForm" ACTION="nextPage.html">
<INPUT TYPE="HIDDEN" NAME="myTextField">
</FORM>

</BODY>
</HTML>

 

In the popupPage.html:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
function copyForm() {
    opener.document.hiddenForm.myTextField.value = document.popupForm.myTextField.value;
    opener.document.hiddenForm.submit();
    window.close();
    return false;
}
//--></SCRIPT>
</HEAD>
<BODY>
<FORM NAME="popupForm" onSubmit="return copyForm()">
<INPUT TYPE="TEXT" NAME="myTextField">
<INPUT TYPE="BUTTON" VALUE="Submit" onClick="copyForm()">
</FORM>
</BODY>
</HTML>

http://developer.irt.org/script/338.htm 
0
 
LVL 2

Accepted Solution

by:
Marianne earned 800 total points
ID: 7013372
You should state
<script>window.opener.name="main";</script>
in your popup, and correspondingly put target in form tag:
<form target=main ... >
0
 

Author Comment

by:barakori
ID: 7019627
leveret - Excellent and elegant solution.
Kudos.
0
 
LVL 2

Expert Comment

by:Marianne
ID: 7021046
barakori,

:-)
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

721 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