title: Javascript pass value from popup page to parent
body: <p>I have a parent page that opens a popup page. on the popup page the user can select a value which is passed back to the parent page.</p>
  
  <p>The code snippet on the parent page is:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;  
  function selectValue(id) 
  { 
      // open popup window and pass field id 
      window.open('sku.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; 
  } 
  
  &lt;/script&gt; 
  </code></pre>
  
  <p>and the code snippet for tha popup age is:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  function sendValue(value) 
  { 
      var parentId = &lt;?php echo json_encode($_GET['id']); ?&gt;; 
      window.opener.updateValue(parentId, value); 
      window.close(); 
  } 
  &lt;/script&gt; 
  </code></pre>
  
  <p>I need to change the popup page code so that the user can select a category which takes them to another page(Still in the popup page). Now when in this page they select the value, it is not passed back to the parent page as the parent page has changed.</p>
  
  <p>Ho can I edit the popup code to point back to the original parent page? in my case the parent page is newsalea.php. Can I do something like:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  function sendValue(value) 
  { 
      var parentId = &lt;?php echo json_encode($_GET['id']); ?&gt;; 
      window.opener.updateValue(newsale.php, value); 
      window.close(); 
  } 
  </code></pre>
  
  <p>This way I hardcode the parentid into the popup pages? is this possible?</p>
  
  <p>Thanks,
  Ryan
       </p>