title: PHP determining what to insert into parent window textarea from child window using radio buttons in child window
body: <p>Hi everyone im new to php and would like to know how if it is possible determine what to insert into parent window textarea from child window using radio buttons in child window. How should I go about doing it? I would much appreciate it if anyone could provide some help on this. Below is the code. Thanks.</p>
  
  <p>Parent Window:</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type='text/javascript'&gt;
  window.onload = function()
  {
    document.getElementById('b1').onclick = openChild;
  }
  function openChild()
  {
    this.disabled = false;
    xWinOpen('retrievemath.php');
  }
  var xChildWindow = null;
  function xWinOpen(sUrl)
  {
    // Modify 'features' to suit your needs:
    var features = "left=100,top=100,width=400,height=400,location=0,menubar=0," +
      "resizable=1,scrollbars=1,status=0,toolbar=0";
    if (xChildWindow &amp;&amp; !xChildWindow.closed) {xChildWindow.location.href  = sUrl;}
    else {xChildWindow = window.open(sUrl, "myWinName", features);}
    xChildWindow.focus();
    return false;
  }
  &lt;/script&gt;
  &lt;script src="ckeditor/ckeditor.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10" &gt;&lt;/textarea&gt;
  &lt;form&gt;
  &lt;input type="button" id ="b1" onClick="myPopup2()" value="POP2!"&gt;
  &lt;/form&gt;
  &lt;p onClick="myPopup2()"&gt;CLICK ME TOO!&lt;/p&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Child Window:</p>
  
  <pre><code>&lt;?php
  include ('database_connection.php');
    $dbConn = mysql_connect('localhost', 'root', '')
               or trigger_error(mysql_error(), E_USER_ERROR);
    // select the database for use
    mysql_select_db('test', $dbConn);
  $query_retrieve_expression = "SELECT * FROM math";
   $queryResource = mysql_query($query_retrieve_expression, $dbConn) or die(mysql_error());
  ?&gt;
  
  &lt;head&gt;
  
  &lt;script type='text/javascript'&gt;
  window.onload = function()
  {
    document.getElementById('f1').onsubmit = sendToParent;
  }
  function sendToParent()
  {
    if (window.opener) {
      var cta = document.getElementById('&lt;?php echo $row['mathID']?&gt;');
      var pta = window.opener.document.getElementById('editor1');
      pta.value = cta.value;
      window.opener.focus();
    }
    return false;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
          &lt;form action="retrievemath.php" method="post" id="f1"&gt;
  &lt;table class="hovertable"&gt;
  &lt;tr&gt;
      &lt;th&gt;Insert ?&lt;/th&gt;&lt;th&gt;Expression Name&lt;/th&gt;&lt;th&gt;Math Expression&lt;/th&gt;
  &lt;/tr&gt;
  
      &lt;?php
                 while($row = mysql_fetch_assoc($queryResource))
                 {     
      ?&gt;
  
                      &lt;tr&gt; 
                      &lt;td&gt;&lt;input type="radio" name="insert" id="&lt;?php echo $row['mathID']?&gt;" value="&lt;?php echo $row['expressionname']?&gt;" /&gt; &lt;/td&gt; 
                      &lt;td&gt;&lt;?php echo $row['expressionname']; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['mathexpression']; ?&gt;&lt;/td&gt; 
                      &lt;/tr&gt;
  
      &lt;?php
                 }
      ?&gt;
  
  
  &lt;/table&gt;
  
  
  
      &lt;div class="submit"&gt;
        &lt;input type="submit" value="Insert" /&gt;
      &lt;/div&gt;
          &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>