Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:17:03+00:00 2026-06-04T18:17:03+00:00

I have a working script that passes a value from a popup page to

  • 0

I have a working script that passes a value from a popup page to the parent page.

Process Flow is:
ParentPage>ChildPage>ParentPage

I have had to change the process flow of my little application to have a ‘category select’ option on the child page. the process flow is now:
ParentPage>ChildPage1>ChildPage2>ParentPage

My application now requires the user to select a value from a popup. the first popup will provide a category choice. once a category is chosen the category products are shown on the next page. the user then selects a product from the options and the value is passed to the original parent page.

I hope I have explained my problem accurately. How can I pass the selected value back to the original parent page. if my parents page is named parent.php, can I hard code the ID of page parent.php into my code:

window.opener.updateValue(parentId, value);

Any assistance is always appreciated.

My working code and proposed code is shown below:

WORKING CODE

parent.php

<html>
<head>
<title>test</title>

<script type="text/javascript">  
function selectValue(id) 
{ 
    // open popup window and pass field id 
    window.open('child.php?id=' + encodeURIComponent(id),'popuppage', 
      'width=400,toolbar=1,resizable=1,scrollbars=yes,height=400,top=100,left=100'); 
} 

function updateValue(id, value) 
{ 
    // this gets called from the popup window and updates the field with a new value 
    document.getElementById(id).value = value; 
} 

</script> 
</head>

<body>

<table> 

<tr>
<th>PACK CODE</th>
</tr>

<tr>  
    <td>
        <input size=10  type=number id=sku1 name=sku1 ><img src=q.png  name="choice" onClick="selectValue('sku1')" value="?">
    </td>
</tr>
<tr> 
    <td>
        <input size=10  type=number id=sku2 name=sku2 ><img src=q.png  name="choice" onClick="selectValue('sku2')" value="?">
    </td>
</tr>
</table>


</body>
</html>

child.php

<script type="text/javascript"> 
function sendValue(value) 
{ 
    var parentId = <?php echo json_encode($_GET['id']); ?>; 
    window.opener.updateValue(parentId, value); 
    window.close(); 
} 
</script> 
<table> 
    <tr> 
        <th>Pack Code</th>                       
    </tr> 
    <tr> 
        <td>1111</td> 
        <td><input type=button value="Select" onClick="sendValue('1111')" /></td>
    </tr>
    <tr> 
        <td>2222</td> 
        <td><input type=button value="Select" onClick="sendValue('2222')" /></td>
    </tr>
    <tr> 
        <td>3333</td> 
        <td><input type=button value="Select" onClick="sendValue('3333')" /></td>
    </tr>
</table> 

PROPOSED CODE

parent.php

<html>
<head>
<title>test</title>

<script type="text/javascript">  
function selectValue(id) 
{ 
    // open popup window and pass field id 
    window.open('child1.php?id=' + encodeURIComponent(id),'popuppage', 
      'width=400,toolbar=1,resizable=1,scrollbars=yes,height=400,top=100,left=100'); 
} 

function updateValue(id, value) 
{ 
    // this gets called from the popup window and updates the field with a new value 
    document.getElementById(id).value = value; 
} 

</script> 
</head>

<body>

<table> 

<tr>
<th>PACK CODE</th>
</tr>

<tr>  
    <td>
        <input size=10  type=number id=sku1 name=sku1 ><img src=q.png  name="choice" onClick="selectValue('sku1')" value="?">
    </td>
</tr>
<tr> 
    <td>
        <input size=10  type=number id=sku2 name=sku2 ><img src=q.png  name="choice" onClick="selectValue('sku2')" value="?">
    </td>
</tr>

</table>

</body>
</html>

child1.php

<script type="text/javascript"> 
function sendValue(value) 
{ 
    var parentId = <?php echo json_encode($_GET['id']); ?>; 
    window.opener.updateValue(parentId, value); 
    window.close(); 
} 
</script> 
 <form name="category" method="POST" action=child2.php>
<table> 
<tr> 
<td>Category</td>
</tr> 
<tr> 
<td>
<select name="category" id="category">
   <option value="1">1</option>
   <option value="2">2</option>
   <option value="3">3</option>
   <option value="4">4</option>
 </select> 
</td>  
</tr> 
<tr>
<td>
<input type=submit value=next>
</td>
</tr>
</table> 

Child2.php

<script type="text/javascript"> 
function sendValue(value) 
{ 
    var parentId = <?php echo json_encode($_GET['id']); ?>; 
    window.opener.updateValue(parentId, value); 
    window.close(); 
} 
</script> 


<?

$category=$_POST[category];

?>
 <form name="selectform"> 
 <table>
    <tr> 
    <tr> 
        <th>Pack Codes for Category <? echo $category; ?></th>                       
    </tr> 
    <tr> 
        <td>1111</td> 
        <td><input type=button value="Select" onClick="sendValue('1111')" /></td>
    </tr>
    <tr> 
        <td>2222</td> 
        <td><input type=button value="Select" onClick="sendValue('2222')" /></td>
    </tr>
    <tr> 
        <td>3333</td> 
        <td><input type=button value="Select" onClick="sendValue('3333')" /></td>
    </tr>
    </table>

I know popup pages are not the desired option in this situation but this is where my application is at. Please advise on how I can alter the code on child 2 to point back to the parent.php page. My thinking is to change code below

<script type="text/javascript"> 
function sendValue(value) 
{ 
    var parentId = <?php echo json_encode($_GET['id']); ?>; 
    window.opener.updateValue(parentId, value); 
    window.close(); 
} 
</script> 

to this code (hard code the parent ID in – what would this be for parent.php)

<script type="text/javascript"> 
function sendValue(value) 
{ 
    var parentId = <?php echo json_encode($_GET['id']); ?>; 
    window.opener.updateValue('parent.php', value); 
    window.close(); 
} 
</script> 

Many Thanks,
Ryan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:17:05+00:00Added an answer on June 4, 2026 at 6:17 pm

    Ok, here is a summary of my architecture proposition:

    main:

    var oChild = window.popup('child1.php');
    oChild.openerr = window;
    

    child1.php:

    var oWin = window.popup('child2.php');
    oWin.category = document.getElementById('category').value;
    oWin.openerr = window;
    //here use window.openerr to access the parent (main)
    

    child2.php:

    var g_oXhr = new xmlHttpRequest();
        g_oXhr.onreadystatechange = function() {
            if (g_oXhr.readyState == 4 && (g_oXhr.status == 200)) {
                //use g_oXhr.responseText or g_oXhr.responseXML
            }
        }
    
        g_oXhr.open("POST", "mysql_query_elements_category.php", true);
        g_oXhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
        g_oXhr.send('0=' + encodeURIComponent(window.category));
    
        //here use window.openerr to access the parent (child1)
    

    here we go 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that generates images from text using PHP. It's working fine
I have working registration script the only problem is that i do not know
I created a shutdown.py script that shuts down my computer. I have a working
I have a script that I'm trying to get working. Basically, what I'm trying
I have been working on a build script for a website that we have.
I have a working script from someone, there in is this line: this.event =
I have an application script that is working correctly, but I have a few
I have a JS function that passes a json string to a PHP script
i have my script working but currently it used a button input, i want
I have a script working well for creating ad hoc iPhone builds. I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.