I am having a major issue that i want to add some data to a table row on specific td by adding multiple input elements with the help of ajax. I'm also able to do that but my issue is when i have multiple rows on table and i add the element it add on the first row of table but i want to add to that row only here what im trying to do.
the code i'm using for it
<script type="text/javascript" src="assets/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
<script type="text/javascript">
var counter = 1;
function dep()
{
if(counter>9){
alert("Only 10 textboxes allow");
return false;
}
var newTextBoxDiv = jQuery(document.createElement('div'))
.attr("id", 'dependent' + counter);
newTextBoxDiv.after().html( '<input type="text" class="form-control" name="checklistname[]' + counter + '" placeholder="Add Checklist" required>');
newTextBoxDiv.appendTo("#dependent");
counter++;
}
function depdel()
{
if(counter==1){
alert("No more textbox to remove");
return false;
}
counter--;
jQuery("#dependent" + counter).remove();
}
</script>
<table>
<thead>
<tr class="myrows">
<th>Project </th>
<th>Action</th>
</tr>
</thead>
<tr>
<?php for($i=0;$i<=2;$i++) { ?>
<td>my project<?php echo $i;?></td>
<td> <form action="" method="post" id="form">
<div id="dependent" class="newclass">
</div>
<input type="submit" id="mybutton" value="Save" title="Save">
<a href="#" class="action" title="Add" onClick="dep();"> Add </a>
<a href="#" class="action" title="Delete" onClick="depdel();">delete </a>
</td>
<?php }?>
</tr>
</table>
kindly check the screenshot and the html is to show what i'm trying to do. thanks