title: How to get value of Element ID from dynamic table
body: <p>My question here is how to get the element id value from dynamic input text with [$i] from this
  <code>&lt;input type='text' class='form-control num-only 'id='price[$i]' /&gt;</code></p>
  <p>full Code:</p>
  <pre><code>&lt;html&gt;
     &lt;body&gt;
        &lt;p id=&quot;demo&quot;&gt;Create Invoice&lt;/p&gt;
        &lt;table class=&quot;table table-bordered table-responsive&quot; id=&quot;crud_table&quot;&gt;
           &lt;tr&gt;
              &lt;th class=&quot;&quot; &gt;#&lt;/th&gt;
              &lt;th class=&quot;&quot; &gt;Product&lt;/th&gt;
              &lt;th class=&quot;&quot; &gt;Item Price&lt;/th&gt;
              &lt;th class=&quot;&quot; &gt;Quantity&lt;/th&gt;
              &lt;th class=&quot;&quot; &gt;inStore&lt;/th&gt;
              &lt;th class=&quot;&quot; &gt;New Quantity&lt;/th&gt;
              &lt;th class=&quot;&quot; &gt;Total&lt;/th&gt;
           &lt;/tr&gt;
           &lt;tbody&gt;
              &lt;?php for ($i = 1; $i &lt;= 2; $i++) { 
             echo&quot; 
              &lt;tr&gt;
                 &lt;td align='center'&gt;&lt;?php echo $i;?&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type='text' class='form-control ' value=''   id='itemname[$i]' /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type='text' class='form-control num-only '     id='price[$i]' /&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type='number' class='form-control num-only'  maxlength='5' id='quantity[$i]' onchange='kofta(this)'/&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type='text' class='form-control num-only'   maxlength='50' id='inStore[$i]'  onchange='kofta()'/&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type='text' class='form-control num-only'   maxlength='10' id='newq[$i] ' onchange='kofta()'/&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input type='text' class='form-control num-only'   maxlength='50' id='total[$i]' readonly /&gt;&lt;/td&gt;
              &lt;/tr&gt; &quot;;
               } ?&gt;
           &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;input type=&quot;text&quot; id=&quot;total&quot; readonly value=&quot;0&quot;&gt;
         
        &lt;script&gt;
           function kofta(){
           var rate= document.getElementById(&quot;price&quot;).value;
           var q1=document.getElementById(&quot;quantity&quot;).value
           var total= rate * q1;
           document.getElementById(&quot;total&quot;).value=total;
           }
           
        &lt;/script&gt;
         
  
  </code></pre>
  <p>How i can get the value ?? so i can calculate the values
  total = price * quantity
  total of all rows in total input text</p>