I have a "checkbox table" and I need to save it in the BD, obviously I'll need to show it later, but I do not know the best way to do it, I'm exhausted from the service and I can not think straight.
Follow the code:
$("#addCronogramaFisico").click(function(){
addCronogramaFisico();
})
i=0;
function addCronogramaFisico(){
var j = i+13;
tableFisico = ""+
"<tr bgcolor='#F0F0F0'>"+
"<td><input type='text' name='novoCronogramaFisico[]' placeholder='Digite o novo Cronograma'></td>";
for(i;i<j;i++){
tableFisico += ""+
"<td>"+
"<section title='.squaredTwo'>"+
"<div class='squaredTwo'>"+
"<input type='checkbox' value='none' id='squareCF"+i+"' name='cb[]'>"+
"<label for='squareCF"+i+"'></label>"+
"</div>"+
"</section>"+
"</td>";
}
tableFisico += ""+
"<td align='center'><img width='18' class='imgDel' src='../img/minus.png'></td>"+
"</tr>";
$("#projetoFisicoFixo").append(tableFisico);
removeCronogramaFisico();
}
function removeCronogramaFisico(){
$(".imgDel").click(function(){
$(this).parent().parent().html("");
// console.log($(this).parent().parent().parent());
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><palign="center" class="dest">Cronograma Físico:<span class="instrucoes">(Tempo necessário para cada fase do projeto para atingir os objetivos)</span><img width="18" src="../img/plus.png" id="addCronogramaFisico"></p>
<table width="520" border="1" align="center" cellspacing="0" cellpadding="0" id="projetoFisicoFixo">
<tr>
<th>Mês</th>
<th>12</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
<th>12</th>
</tr>
<tr>
<td>Estruturação do Plano</td>
<? for($i=0;$i<13;$i++){ ?>
<td>
<section title=".squaredTwo">
<div class="squaredTwo">
<input type="checkbox" value="" id="squareEP<?=$i?>" name="cf0[]" />
<label for="squareEP<?=$i?>"></label>
</div>
</section>
</td>
<? } ?>
</tr>
<tr>
<td>Apresentação do plano a Direção</td>
<? for($i=0;$i<13;$i++){ ?>
<td>
<section title=".squaredTwo">
<div class="squaredTwo">
<input type="checkbox" value="None" id="squareAP<?=$i?>" name="cf1[]" />
<label for="squareAP<?=$i?>"></label>
</div>
</section>
</td>
<? } ?>
</tr>
<tr>
<td>Encaminhamento à Gerência de Projetos SMED</td>
<? for($i=0;$i<13;$i++){ ?>
<td>
<section title=".squaredTwo">
<div class="squaredTwo">
<input type="checkbox" value="None" id="squareEG<?=$i?>" name="cf2[]" />
<label for="squareEG<?=$i?>"></label>
</div>
</section>
</td>
<? } ?>
</tr>
</table>
The code does not run because it has php in the middle, but just copy to a server.
My current table to save looks like this:
CREATE TABLE educacao.cronograma_fisico
(
id serial NOT NULL PRIMARY KEY,
id_projeto INTEGER REFERENCES educacao.projetos ON DELETE CASCADE,
id_descricao varchar(255) NOT NULL,
ano varchar(4) NOT NULL,
mes0 boolean,
mes1 boolean,
mes2 boolean,
mes3 boolean,
mes4 boolean,
mes5 boolean,
mes6 boolean,
mes7 boolean,
mes8 boolean,
mes9 boolean,
mes10 boolean,
mes11 boolean,
mes12 boolean,
user_alteracao varchar(50),
dt_alteracao date,
hr_alteracao character(5)
)
WITH (
OIDS=TRUE
);
Anyway, what's the best way to get these checkboxes and save them in BD? Remembering that I need to save the line name too. Thanks