By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,619 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,619 IT Pros & Developers. It's quick & easy.

copy popupwindow elements to opener

P: n/a
Hi,

I have a html form which is created by a cgi-script which sometimes
opens a popup window. This popup window reads it's content from a hidden
field in the openers form and writes it through document.write. The
content of this popup itself can also be small forms for example a
couple of radio button or textfields or things like that and every popup
has it's own "save" button,

When the user clicks "save" I have to read all the form elements in the
popup window and attach it to the window.opener form before submitting
that and closing the popup because I still need all the values from the
opener form plus the additional form fields from the popup.

I already tried looping through all the form elements and adding them
through appendChild to the opener. Problem is this crashes IE6 right
after it says "interface not supported", it works on Firefox 1.0 but it
must work on both browsers. I also tried to somehow clone the form
elements and then adding these clones to the parent, but you can't clone
form elements because you get a recursion too deep, because they are
linked to superclass objects, and therefore when you try to clone a form
object you end up in a loop. for example
document.forms.form.myfield.form.myfield.form.myfi eld.form.... and so on

Does anyone have a solution how I can add these form values to my parent
window before submitting it?? Any ideas are welcome.

Marc
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lee
Marc Elser said:

Hi,

I have a html form which is created by a cgi-script which sometimes
opens a popup window. This popup window reads it's content from a hidden
field in the openers form and writes it through document.write. The
content of this popup itself can also be small forms for example a
couple of radio button or textfields or things like that and every popup
has it's own "save" button,

When the user clicks "save" I have to read all the form elements in the
popup window and attach it to the window.opener form before submitting
that and closing the popup because I still need all the values from the
opener form plus the additional form fields from the popup.


You're creating the form with CGI, so you can simply add all of the
form controls that you need when you create it, then you only have to
set the values from the popup window.

Jul 23 '05 #2

P: n/a
Lee wrote:

You're creating the form with CGI, so you can simply add all of the
form controls that you need when you create it, then you only have to
set the values from the popup window.

Well it's not that simple. The content of the popup is totally dynamic
and created elsewhere in the program and then only attached to the
bottom of the html form.

Because of that the form parsing in the popup would of totally dynamic
forms is quite difficult to parse when it comes to certain form field
types. For example to detect which radio button was selected out of a
group of three. Because when looping through the form fields you would
have to detect which radio button elements belong together and which was
selected in order to set this value in the openers form, or for example
parse which options we're selected in a multiselect element.

The difficulty is not how to set the form fields in the opener, the
difficulty is how to parse the popup's form. once you know the name and
value of an element you can append it to the opener using the
"appendChild" javascript function.

To overcome this parsing I thought that maybe there's a possibility to
clone or copy the form elements and then adding them to the opener. But
unlike java javascript has no support of cloning objects and the
javascript example I found for cloning object we're not able to clone a
html form object correctly so that you could add them with appendChild.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.