hi I want to pick an item from list of items in table A and it should be displayed in table B. Afterwards, i want to click submit button in table B to save the picked items from Table A. The problem is I put in an age input field in my for each in table A but when i try to pass it to table b, it passes just the input value of the first item in the for each, how can i make the input field unique. this is my code

```
<?php
$data=array();
$i=0;
$notarray = DataDB::getInstance()->get_rows_from_field('inventory','branch_id',$branchid);
foreach($notarray as $row){
    $data[$i]=$row;
    $i++;
}
?>

<table class="table table-bordered datatable" id="table_export">
    <thead>
        <tr>
            <th>#</th>
            <th><div>name</div></th>
            <th><div>surname</div></th>
            <th><div>date</div></th>
            <th><div>Age</div></th>
            <th><div>action</div></th>

        </tr>
    </thead>
    <tbody>

        <?php
        $i=0;
        for ($i=0;$i<count($data);$i++) {
            $item=$data[$i];
            $count = 1;
            ?>

            <tr>

                <td><?php echo $count++;?></td>
                <td><?php echo $item['name'];?></td>
                <td><?php echo $item['surn'];?></td>
                <td><?php echo $item['date']; ?></td>

                <form method="post" action="" role="form">
                    <td>

                        <div class="form-group">

                            <div class="">
                                <input type="number" class="form-control" name="age" data-validate="required" data-message-required="Age required" autofocus>
                            </div>
                        </div>

                    </td>

                    <td>

                        <div class="btn-group">
                            <button type="submit" class="btn btn-primary" id="addb" name="save" onclick='addToList(<?php echo json_encode($item);?>);'>Add</button>
                        </div>
                    </td>
                </form>

            </tr>

            <?php
        }

        ?>

    </tbody>
</table>

<br><br>

<div id="showToSave">
</div>

<script type="text/javascript">

    var listToSave=[]; // must be global

    var addToList= function(data){

        var button = document.getElementById("addb"),
        value =  button.form.quantity+"Panadol".value;
        data.quan = value;
        var lenData=listToSave.length;
        if(lenData>0){
                //this is used to avoid duplicate
            for(var j=1;j<lenData;j++){
                if(data.id==listToSave[j].id) return;
            }
        }

        listToSave.push(data);
        console.log(listToSave);
        document.getElementById('showToSave').innerHTML=createData(listToSave);

    };

    var createData= function (data) {

        var len=data.length;
        var tableToSave="<table class='table table-bordered datatable'><tr><td>Item</td> <td>Quantity</td> <td>Price</td> <td>Action</td></tr>";
        var i;
        for(i=0;i<len;i++){
            content=data[i];

            tableToSave += "<tr><td>"+content.item_name+"</td><td>"+content.quan+"</td><td>"+content.price+"</td><td>" +
            "<button class='btn btn-danger' onclick='deleteFromSave("+i+")'>Delete</button></td></tr>";
        }
        tableToSave += "</table><div><button class='btn btn-success' onclick='saveData()' type='button'>Save</button></div>";
        return tableToSave;
    };

    var deleteFromSave=function (index) {
        listToSave.splice(index,1); //this is use to delete from list to save
        document.getElementById('showToSave').innerHTML=createData(listToSave); //to rerender after delete
    };
</script> 

```