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?

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!

   

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.

[code]wow, what a beating...

second window: 

window.opener.myvar=window.self;[/code]

 

first window function:

myvar.document.getElementById.....

 

Thanks for the help, it was a shove in the right direction and I couldn't have figured it out otherwise.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.