title: how to read the input values from a dynamic html table?
body: <p>i have the following code to read the values from a regular input,</p>
  
  <p>HTML:</p>
  
  <pre><code>     &lt;tr&gt;
    &lt;th&gt;Email:&lt;/th&gt;     
      &lt;td&gt;&lt;input id="email"  name="email" onchange="EmailValidate()" maxlength="50"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>      file_put_contents($file, "\nEMAIL:", FILE_APPEND | LOCK_EX);
  
    $ret = file_put_contents($file, $_POST['email'], FILE_APPEND | LOCK_EX);
  </code></pre>
  
  <p>in the same way, i am trying to read the input values from a dynamically generated html table, but i am getting an error,</p>
  
  <p>HTML:</p>
  
  <pre><code>     &lt;table&gt;
    &lt;tr&gt;
    &lt;th&gt;Number of Models:&lt;title="Number of Models"&gt;&lt;/th&gt;
  
    &lt;td&gt;&lt;select id="numbermodels" name="numbermodels"       onchange="buildTable(this.value); buildTable4(this.value);"&gt;
  
    &lt;option value="1"&gt;1&lt;/option &gt;
    &lt;option value="2"&gt;2&lt;/option &gt;
    &lt;option value="3"&gt;3&lt;/option &gt;
    &lt;option value="4"&gt;4&lt;/option &gt;
    &lt;option value="5"&gt;5&lt;/option &gt;
    &lt;option value="6"&gt;6&lt;/option &gt;
    &lt;/select&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;th&gt;Number of heads per model:&lt;/th&gt;
    &lt;td&gt;
    &lt;table id="contentTable" border="1" name="contentTable"&gt;
      &lt;!-- Fill table programmatically --&gt;
        &lt;/table&gt;&lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>      function buildTable(val)
        {
       var myTable =document.getElementById("contentTable");
      var j=val;
          var rows = [];
      var cells = [];
  
       while (myTable.hasChildNodes()) {
       myTable.removeChild(myTable.lastChild);
        }
  
  
        for( var i = 0; i &lt; 1; i++ )
         {
         rows[i] = myTable.insertRow(i);
         if(i%3==2)rows[i].addClass("every3rdrow");
           cells[i] = [];
  
         for( var x = 0; x &lt; j ; x++ )
        {
          cells[i][x] =document.createElement((x==0)?"th":"td");
          cells[i][x].innerHTML = (x==0)?"&lt;input id=t onchange=ty() name=t&gt;":"&lt;input     id=t onchange=ty()&gt;";
          rows[rows.length - 1].appendChild(cells[i][x]);
          }
          }
  
           }
               buildTable();  
  
           function ty(){
        $ad = document.getElementById("t").value;
        if(!/^-?\d*$/.test($ad)) {
         alert("Number of heads per model value must be numeric!");
         } 
         } 
  </code></pre>
  
  <p>for this also i wrote the similar PHP code, but i am getting the error Undefined index t,
  PHP:</p>
  
  <pre><code>      file_put_contents($file, "\n Number of Heads per Model:", FILE_APPEND | LOCK_EX);
  
  $ret = file_put_contents($file, $_POST['t'], FILE_APPEND | LOCK_EX);
  </code></pre>
  
  <p>what is the reason for this, what modifications can be done to be able to successfully read the input values from the dynamic html table ?</p>