In PHP MySQL, add default POST values to dynamically created input row fields.
<p>I'm developing a small HTML form integrated with a table. The table has an input field called "name" which displays the current date as the default value. This works great for the first row. However, when I add more rows dynamically, the new input fields don't show the default date value. Here is my current code setup: </p>
<pre class="brush:html;toolbar:false;"><html>
<body>
<table class="table table-bordered">
<thead class="table-success" style="background-color: #3fbbc0;">
<tr>
<th width="15%"><center>Service</th>
<th width="5%"></th>
<th>
<button type="button" class="btn btn-sm btn-success" onclick="BtnAdd()">Add Item</button>
</th>
</tr>
</thead>
<tbody id="TBody">
<tr id="TRow" class="d-none">
<td><input type="text" name="name[]" id="name" value="<?php echo date("Y-m-d"); ?>"></td>
<td class="NoPrint">
<button type="button" class="btn btn-success" style="line-height: 1;" onclick="BtnDel(this)">x</button>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
// Script to add dynamic rows in the table
function BtnAdd() {
var v = $("#TRow").clone().appendTo("#TBody");
$(v).find("input").val('');
$(v).find("input").autocomplete({ source: 'backend-script.php' });
$(v).removeClass("d-none");
$(v).find("th").first().html($('#TBody tr').length - 1);
}
function BtnDel(v) {
$(v).parent().parent().remove();
$("#TBody").find("tr").each(function(index) {
$(this).find("th").first().html(index);
});
}
</script>
</body>
</html>
</pre>
<p>I need some guidance on how to make these dynamically created fields also display the current date as their default value. Thank you very much for your help with my study project. </p>