Jump to content

[SOLVED] changing field values inside a popup from another popup


michaellunsford

Recommended Posts

I have a popup form with another popup to select a value for one field. It's late, so I hope I can explain this where it makes sense.

 

WYSIWYG Editor is popping up "insert image" form dialogue. There is an upload image button that fires yet another popup window with upload dialogue. Trying to pass a value to the "insert image" window's "URL" field from the "upload image" popup. Instead of pointing to the actual calling window (insert image), "window.opener.document.forms[0]" is actually pointing to the WYSIWYG editor window's forms[0].

 

What to do?

Link to comment
Share on other sites

the 'window.opener' can also be used to run a function in the opening window:

window.opener.somefunction();

maybe you pass a function in the opener the datavalue to pass, the window name to pass it to, and the form/field name in that window to 'push' it in:

window.opener.pushvalue(towindowname, toformname, tofieldname, datavalue);

the pushvalue() function would contain code to actually 'push' the datavalue into the specified window/field. I think you have to store the window.open in a var:

var shoppingWin = 
      window.open('','shoppingWin','width=400,height=300,scrollbars=1');
      if(shoppingWin.focus) { shoppingWin.focus(); } //altering child window!

   

Link to comment
Share on other sites

ugh

 

the parent window has a function that pushes data to the second window:

win.document.getElementById('prev').innerHTML = '<img src="' + (win.document.forms[0].elements[field_name].value) + '" />';

the code works great when called from the same window, but gives a "win.document has no properties" error when called from the third window.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.