I need to use this form to update the table, but the datepicker returns nothing in "POST", form without datepicker works, form outside the table with the dapicker works this 3 one inside other doesnt works, if form is outside the table, buttons will always post last row data. please help me! CODE:
<form action="footer.view.php" id="aggio" method="POST">
<table id="fatture">
</tr>
<?php $i = 0; ?>
<?php foreach ($risultato as $fatture) :
$timestamp = date_create_from_format('Y-m-d', $fatture["dataEmissione"]);
$dataEmissione = date_format($timestamp, "d/m/Y");
if ($fatture["dataPagamento"] != "") {
$timestamp = date_create_from_format('Y-m-d', $fatture["dataPagamento"]);
$dataPagamento = date_format($timestamp, "d/m/Y");
} else {
$dataPagamento = "";
} ?>
<tr id="sub<?php echo($i)?>">
<!-- ../includes/invoice.inc -->
<td><input name="numeroFattura" class="form-control" value="<?php echo ($fatture["numeroFattura"]); ?>" placeholder="<?php echo ($fatture["numeroFattura"]); ?>"></td>
<td><div class="input-group" role="wrapper">
<span class="input-group-append" role="left-icon">
<button class="btn btn-outline-secondary border-right-0" type="button">
<i class="gj-icon">€</i>
</button>
</span>
<input role="input" step="0.01" type="number" name="importo" title="Currency" value="<?php echo ($fatture["importo"]); ?>" placeholder="<?php echo ($fatture["importo"]); ?>" pattern="^\d+(?:\.\d{1,2})?$" onblur="this.parentNode.parentNode.style.backgroundColor=/^\d+(?:\.\d{1,2})?$/.test(this.value)?'inherit':'red'" class="form-control" ></div>
</div></td>
<td><input name="dataEmissione" id="dataEmissione<?php echo ($i); ?>" placeholder="<?php echo ($dataEmissione); ?>" value="<?php echo ($dataEmissione); ?>" width="150" required />
<script>
$('#dataEmissione<?php echo ($i); ?>').datepicker({
uiLibrary: 'bootstrap4',
format: 'dd/mm/yyyy'
});
</script>
</td>
<td><input name="dataPagamento" id="dataPagamento<?php echo ($i); ?>" placeholder="<?php echo ($dataPagamento); ?>" value="<?php echo ($dataPagamento); ?>" width="150" />
<script>
$('#dataPagamento<?php echo ($i); ?>').datepicker({
uiLibrary: 'bootstrap4',
format: 'dd/mm/yyyy'
});
</script>
</td>
<?php if ($fatture["emessa"] == 1) {
?>
<td><input name="emessa" type="checkbox" class="form-check" checked> </td>
<?php
} else {
?>
<td><input name="emessa" type="checkbox" class="form-check"></td>
<?php
} ?>
<?php if ($fatture["pagata"] == 1) {
?>
<td><input name="pagata" type="checkbox" class="form-check" checked> </td>
<?php
} else {
?>
<td><input name="pagata" type="checkbox" class="form-check"> </td>
<?php
} ?>
<input type="hidden" value="<?php echo ($ordine) ?>" name="ordine">
<td><button class="btn btn-primary" name="aggiorna" value="<?php echo ($fatture["idFattura"]); ?>" form="aggio" id="sub<?php echo($i)?>" type="submit">AGGIORNA</button></td>
</tr>
<?php
$i++;
endforeach; ?>
</table>
</form>