Jump to content

passing info from popup to a parent window


Lodius2000

Recommended Posts

first let me say, I know very little about javascript, i work in php. regardless

 

I have a popup with a file upload on it, when the file is uploaded it performs a mysql query which generates a sequential id number for that file, I would like to transfer that id number to a text field on the parent window and then add a comma after the image,(so i want the text field to look like: 1,2,3,4,5 ... but have no idea how.

 

a few things that I think would be needed are this, the ID number on the popup is a php variable called $img_id, the form on the parent page's form is called 'entry' and the text field that $img_id would go to is called 'images'

 

thanks for any help you can provide

Link to comment
Share on other sites

i am unsure if this works in your situation, but you could try

 

parent.<function>.

 

example:

in the pop-up call a function in the parent window by going

<script>

    parent.callFunction(var1, var2, ....);

</script>

 

and obviously that function will have to exist in the parent. When calling the popup you might have to give it a parent id (not 100% sure as i said)

Link to comment
Share on other sites

Create a separate page with your parameter and put it for the value of your text field, ex:


 

Then call a separate function with javascript that creates a pop up window with that page and $_GET the vars via HTTP.  There are plenty of examples online but you should pass it like this:

 

$url = "../page_to_call?img_id=". $img_id . "";

 

Sorry if my code is messy I did this quickly, but I hope it helps you.

Link to comment
Share on other sites

Pop up page:

...
<script type="text/javascript">
var ids = window.opener.getElementById('ids').value;
if (ids.length==0){
  ids = '<?php echo $img_id; ?>';
}
else{
  ids = ids+',<?php echo $img_id; ?>';
}
window.opener.getElementById('ids').value = ids;
</script>
...

 

Parent page:

...
<input type="text" name="images" id="ids" value="">
...

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.