Link to home
Start Free TrialLog in
Avatar of moconn

asked on

Help with Remote Control Window - 500 pts

Hi Experts,

I am having a problem with javascript remote control..

I have found loads of examples on the web of how to create a remote control to redirect the parent window to a new page
but nothing that does what i need..


I have a form (parent window) and a popup (child window). When the popup is opened the user can upload an image I want to populate the path to the image into the relevant field in my parent window when the user closes the child window.


Parent Window


The photo below is the current photo

Change Photo   <----- Opens popup


Browse | Upload

I.e. Once i've uploaded the file in the popup and its been previewed then the user closes the window
and the the path is passed back to the original window | original window refreshed so the user can see the photo.

PS The upload code is working fine, all i need is to be able to pass the url of the photo back to the original page and refresh the original page.


Avatar of Zvonko
Flag of North Macedonia image

The popup can get this access to parent window:
function setParent(){
  var pImg = opener.document.images;
  var pForm = opener.document.forms[0];
  // now you can set the parent image src by the parent image name:

  pImg.PHOTO.src = "images/theUploaded.jpg";  // img.src
  pForm.imagePath.value = "images/theUploaded.jpg";  // form field value

window.onunload = setParent;


Avatar of moconn


Cheers for your answer,

Just want to clarify a couple of things excuse my complete novice at Javascript..

Currently i'm opening the popup in the parent by using this script between the <head> tag

<SCRIPT LANGUAGE="javascript">
var newwindow;
function poptastic(url)
      if (window.focus) {newwindow.focus()}

and this link in within the <body> tag

echo "<a href='javascript:poptastic(\"./upload_photo.php?article_id=$article_id\");'> Change Photo</a><br>";

Questions are:

a. I presume the code above is to be placed within the <head> tag of the popup?
b. Is my popup code in the parent combatible with your code above?
c. How is the updated path [images/theUploaded.jpg] accessible in the parent?
d. Does this code refresh the original parent window?


Avatar of Zvonko
Flag of North Macedonia image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of moconn


That did the trick..

Thanks for all your help..
You are welcome.