How to get name attribute value for dynamically created table using javaScript
<p>i want to save all record of this dynamically created table row into mysql database but i m unable to get name value for dynamically added feilds which  i can use in $_POST method .Kindly help me out .And Also tell me how to convert JavaScript var into Php Variable </p>

<pre><code>&lt;?php 
if(isset($_POST['buton_sumit']))
    {
$nav_id =1;
$item1=$_POST['name1'];
$item1=$_POST['name2'];

echo $item1 + $item2; 
    }
?&gt;



&lt;!DOCTYPE HTML&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt; Add/Remove dynamic rows in HTML table &lt;/TITLE&gt;

&lt;/HEAD&gt;
&lt;BODY&gt;

    &lt;table id="extra" width="499" &gt;
    &lt;th width="24"&gt;R&lt;/th&gt;&lt;th width="19"&gt;Sr.&lt;/th&gt;&lt;th width="133"&gt;Item-Name&lt;/th&gt;&lt;th width="144"&gt;Quantity&lt;/th&gt;&lt;th width="145"&gt;price&lt;/th&gt;
    &lt;/table&gt;
    &lt;form action="table1.php" method="post" name="input"&gt;
    &lt;TABLE id="dataTable" width="350px" border="1"&gt;

        &lt;TR&gt;
            &lt;TD width="24"&gt;&lt;INPUT type="checkbox" name="chk"/&gt;&lt;/TD&gt;
            &lt;TD width="19"&gt; 1 &lt;/TD&gt;
            &lt;TD width="133"&gt; &lt;INPUT type="text" name="name1"/&gt; &lt;/TD&gt;
            &lt;TD width="133"&gt; &lt;INPUT type="text" name="qty1"/&gt; &lt;/TD&gt;
             &lt;TD width="133"&gt; &lt;INPUT type="text" name="price1"/&gt; &lt;/TD&gt;
      &lt;/TR&gt;
&lt;/TABLE&gt;


    &lt;INPUT type="button" value="Add Item" onclick="addRow('dataTable')" /&gt;

    &lt;INPUT type="button" value="Remove Item" onclick="deleteRow('dataTable')" /&gt;
    &lt;INPUT type="submit" value="End Sale" name="buton_sumit" /&gt;
    &lt;/form&gt;
&lt;SCRIPT language="javascript"&gt;
        function addRow(tableID) {

            var table = document.getElementById(tableID);

            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);

            var cell1 = row.insertCell(0);
            var element1 = document.createElement("input");
            element1.type = "checkbox";
            cell1.appendChild(element1);

            var cell2 = row.insertCell(1);
            cell2.innerHTML = rowCount + 1;

            var cell3 = row.insertCell(2);
            var element2 = document.createElement("input");
            element2.type = "text";
            element2.name="name"+ cell2.innerHTML;
            var element2id="myid"+cell2.innerHTML;

            element2.setAttribute('id',element2id);

            cell3.appendChild(element2);

            var cell4 = row.insertCell(3);
            var element3 = document.createElement("input");
            element3.type = "text";
            element3.name="qty"+ cell2.innerHTML;

            cell4.appendChild(element3);

            var cell5 = row.insertCell(4);
            var element4 = document.createElement("input");
            element4.type = "text";
            element4.name="price"+ cell2.innerHTML;

            cell5.appendChild(element4);


        }

        function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length;

            for(var i=0; i&lt;rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox &amp;&amp; true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }


            }
            }catch(e) {
                alert(e);
            }
        }
javascript:(document.write(document.forms[0].elements[2].name))
var myname2=2;
    &lt;/SCRIPT&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;
</code></pre>
