title: Pass the td value to php page using Javascript
body: <p>I have a HTML table the displays record from database.</p>
  
  <p>Below is a screenshot of my table</p>
  
  <p><img src="https://i.stack.imgur.com/jyHl0.png" alt="enter image description here"></p>
  
  <p>There is a <code>button in a TD</code> (i.e column 5,7,9), when I click the button I want to perform function to display a popup box with html table.</p>
  
  <p>Before that I want to pass the value of <code>mcc and mnc</code> and also want to pass the column name (i.e if i clicked the button near 5xx i want pass 5xx if 6xx I want to pass 6xx) to the page where there is a query to display the table. And have separate php code to retrieve th and td from database. </p>
  
  <p>I tried but I don't know how to pass this value to javascript then to php page that contains query to display the table. Thanks</p>
  
  <p>This is my HTML markup:</p>
  
  <pre><code>&lt;table&gt;
      &lt;th style="text-align:center;width:92px"&gt;MCC&lt;/th&gt;
      &lt;th style="text-align:center;width:92px"&gt;MNC&lt;/th&gt;
      &lt;th style="text-align:center;width:92px"&gt;MNP&lt;/th&gt;
  
      &lt;?
      $ColumnNames = mysql_query("SELECT column_name FROM information_schema.COLUMNS WHERE table_name = 'supplierprice' AND column_name NOT
      IN ('supp_price_id','region', 'country', 'networkname', 'mcc', 'mnc', 'mnp'
      )") or die("mysql error"); 
  
      $columnArray=array();
      $i = 0;
  
      while($rows = mysql_fetch_array($ColumnNames))
      {
  
      $columnArray[]=$rows[0];
  
      echo "&lt;th&gt;" . $columnArray[$i] . " &lt;span&gt; &lt;img id='logo'  src='/image/Picture2.png' style='margin:-62px -21px -9px 32px'&gt;&lt;/span&gt;&lt;/th&gt;";
      echo "&lt;th style= 'width:20px;'&gt;&lt;/th&gt;";            
                                     $i++;
      }
                      ?&gt;
  
      &lt;?php    
      $sql = mysql_query("SELECT * FROM supplierprice ");    
          while($rows=mysql_fetch_array($sql))
      {    
      if($alt == 1)
              {
                 echo '&lt;tr class="alt"&gt;';
                 $alt = 0;
              }
              else
              {
                 echo '&lt;tr&gt;';
                 $alt = 1;
              }           
      echo '  &lt;td class="edit region '.$rows["supp_price_id"].'"&gt;'.$rows["region"].'&lt;/td&gt;
              &lt;td class="edit country '.$rows["supp_price_id"].'"&gt;'.$rows["country"].'&lt;/td&gt;
              &lt;td class="edit networkname '.$rows["supp_price_id"].'"&gt;'.$rows["networkname"].'&lt;/td&gt;
              &lt;td id="mcc" class="edit mcc '.$rows["supp_price_id"].'"&gt;'.$rows["mcc"].'&lt;/td&gt;   
              &lt;td id="mnc" class="edit mnc '.$rows["supp_price_id"].'"&gt;'.$rows["mnc"].'&lt;/td&gt;
              &lt;td class="edit mnp '.$rows["supp_price_id"].'"&gt;'.$rows["mnp"].'&lt;/td&gt;';           
  
      $ColumnNames = mysql_query("SELECT column_name FROM information_schema.COLUMNS WHERE table_name = 'supplierprice' AND column_name NOT
      IN ('supp_price_id','region', 'country', 'networkname', 'mcc', 'mnc', 'mnp'
      )") or die("mysql error"); 
      $columnArray=array();
      $i=0;
      while($rows1=mysql_fetch_array($ColumnNames))
      {               
      $columnArray[]=$rows1[0];    
      echo '&lt;td  width="0px;" class="edit '.$columnArray[$i].' '.$rows["supp_price_id"].'"&gt;'.$rows[$columnArray[$i]].'&lt;/td&gt;';  
      echo '&lt;td&gt;&lt;input type="button" onclick="myFunction()" value="" /&gt;&lt;/td&gt;';        
         $i++;
          }            
           echo '&lt;/tr&gt;';
                  }  ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>&lt;script&gt;
  
  function myFunction() {
  
   // Create our XMLHttpRequest object
  var hr = new XMLHttpRequest();
  // Create some variables we need to send to our PHP file
  var url = "testpage2/config.php";
  var mcc = document.getElementById("mcc").value;
  var mnc = document.getElementById("mnc").value;
  var vars = "mcc="+mcc+"&amp;mnc="+mnc;
  hr.open("POST", url, true);
  hr.send(vars); 
  
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>but it not passing the value of mcc and mnc also the column</p>