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 

```
<?php 
if(isset($_POST['buton_sumit']))
    {
$nav_id =1;
$item1=$_POST['name1'];
$item1=$_POST['name2'];

echo $item1 + $item2; 
    }
?>

<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE> Add/Remove dynamic rows in HTML table </TITLE>

</HEAD>
<BODY>

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

        <TR>
            <TD width="24"><INPUT type="checkbox" name="chk"/></TD>
            <TD width="19"> 1 </TD>
            <TD width="133"> <INPUT type="text" name="name1"/> </TD>
            <TD width="133"> <INPUT type="text" name="qty1"/> </TD>
             <TD width="133"> <INPUT type="text" name="price1"/> </TD>
      </TR>
</TABLE>

    <INPUT type="button" value="Add Item" onclick="addRow('dataTable')" />

    <INPUT type="button" value="Remove Item" onclick="deleteRow('dataTable')" />
    <INPUT type="submit" value="End Sale" name="buton_sumit" />
    </form>
<SCRIPT language="javascript">
        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<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }

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

</BODY>
</HTML>

```