The form is created through data obtained from the MySQL database. I would like to save all the data from it by clicking submit.
Problem:
I can only save one line at a time by creating a button in the same <tr>
and with the aid of javascript parent ('tr');
When saving the value of each of the generated text boxes dynamically, I can not write the form completely, that is, what I want.
Form PHP Code
<?php
include('conetar.php');
$result = mysqli_query($conn,"SELECT * FROM 'opcoes' WHERE 'tipo' = 1 ;");
echo "<table class='table table-striped table-hover'id='datatables-example'>
<tr>
</tr>
<tr>
<td></td>
<td class='pure-table'><b>Antes da Instalação do Sistema Operativo</b></td>
<td class='pure-table'><b>Verificação</b></td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tbody data-link='row' class='rowlink'>";
echo "<tr>";
echo "<td> <input type='hidden' name='IDOpcao' value=".$row['IDOpcao']."></td>";
echo "<td>" . $row['Opcao'] . "</td>";
echo "<td style='text-align:center;'> <input type='checkbox' name='Validacao'></td>";
echo "</tr>";
echo "</tbody>";
echo "<input type='hidden' name='IDOpcao' class='form-control' value='". $row['IDOpcao'] . "'>";
}
echo "</table>";
mysqli_close($conn);
?>
<br>
<?php
include('conetar.php');
$result = mysqli_query($conn,"SELECT * FROM 'opcoes' WHERE 'tipo' = 2 ;");
echo "<table class='table table-striped table-hover'id='datatables-example'>
<tr>
<td></td>
<td class='pure-table'><b>Instalação e Configuração (Base)</b></td>
<td class='pure-table'><b>Versão Antiga</b></td>
<td class='pure-table'><b>Versão Nova</b></td>
<td class='pure-table'><b>Verificação Prévia</b></td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tbody data-link='row' class='rowlink'>";
echo "<tr>";
echo "<td> <input type='hidden' name='IDOpcao' value=".$row['IDOpcao']."></td>";
echo "<td>" . $row['Opcao'] . "</td>";
echo "<td> <input type='text' name='VersaoAntiga' id= 'VersaoAntiga-".$row['IDOpcao']."' class='form-control versao_antiga'></td>";
echo "<td> <input type='text' id='VersaoNova-".$row['IDOpcao']."' name='VersaoNova' class='form-control' disabled='true'></td>";
echo "<td style='text-align:center;'><input type='checkbox' name= 'VerificacaoPrevia'></td>";
echo "</tr>";
echo "</tbody>";
echo "<input type='hidden' name='IDOpcao' class='form-control' value='". $row['IDOpcao'] . "'>";
}
echo "</table>";
mysqli_close($conn);
?>
<!--Script para copiar para um ficheiro-->
<script>
$(document).ready(function(e){
$(".versao_antiga").on('input', function(e) {
var elemento = $(this);
var idElemento = elemento.attr("id").split('-')[1];
$("#VersaoNova-" + idElemento).prop('disabled', elemento.val().length == 0);
});
});
</script>
<br>
<!--Script para copiar para um ficheiro-->
<?php
include('conetar.php');
$result = mysqli_query($conn,"SELECT * FROM 'opcoes' WHERE 'tipo' = 3 ;");
echo "<table class='table table-striped table-hover'id='datatables-example'>
<tr>
<td></td>
<td class='pure-table'><b>Instalação e Configuração (Complementar)</b></td>
<td class='pure-table'><b>Versão Antiga</b></td>
<td class='pure-table'><b>Versão Nova</b></td>
<td class='pure-table'><b>Verificação Prévia</b></td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tbody data-link='row' class='rowlink'>";
echo "<tr>";
echo "<td> <input type='hidden' name='IDOpcao' value=".$row['IDOpcao']."></td>";
echo "<td>" . $row['Opcao'] . "</td>";
echo "<td> <input type='text' name='VersaoAntiga' id= 'VersaoAntiga-".$row['IDOpcao']."' class='form-control versao_antiga'></td>";
echo "<td> <input type='text' id='VersaoNova-".$row['IDOpcao']."' name='VersaoNova' class='form-control' disabled='true'></td>";
echo "<td style='text-align:center;'><input type='checkbox' name= 'VerificacaoPrevia' ></td>";
echo "</tr>";
echo "</tbody>";
echo "<input type='hidden' name='IDOpcao' class='form-control' value='". $row['IDOpcao'] . "'>";
}
echo "</table>";
mysqli_close($conn);
?>