How do I do that when I click the remove button and activate the removefield () function, is the page called that would do this delete directly from the mysql database? I need only the part of Jquery for this, since PHP and Mysql I know how to do. See below:
Iambringingthisinformationfromthedatabaseasfollows:
....while($jmTamanhos=mysqli_fetch_object($sql)){$visualizar.="<tr class='linhas'>
<td style=\"padding: 5px\"><input type=\"text\" name=\"Cores[]\" class=\"tamanhos form-control\" placeholder=\"Cor do Produto\" value='".$jmTamanhos->Cores."'></td>
<td style=\"padding: 5px\"><input type=\"text\" name=\"Tamanho[]\" class=\"form-control pull-left\" placeholder=\"Tamanho\" value='".$jmTamanhos->Tamanho."'></td>
<td style=\"padding: 5px\"><input type=\"number\" name=\"EstoqueProd[]\" class=\"form-control pull-left\" placeholder=\"Estoque\" min=\"1\" value='".$jmTamanhos->Estoque."'></td>
<td style=\"padding: 5px\">
<input type='hidden' name='IDEstoques[]' value='".$jmTamanhos->IDEstoques."'>
<button type=\"button\" class=\"removerCampo btn btn-danger\" title=\"Remover linha\"><i class=\"fa fa-minus-square\" aria-hidden=\"true\"></i> Remover</button>
</td>
</tr>";
}
$visualizar .= " <tr><td colspan=\"3\"><button type=\"button\" class=\"adicionarCampo btn btn-primary\" title=\"Adicionar item\"><i class=\"fa fa-plus-square\" aria-hidden=\"true\"></i> Adicionar mais tamanhos</button></td></tr>";
....
And Jquery:
<script type="text/javascript">
$(function () {
removeCampo();
function removeCampo() {
$(".removerCampo").unbind("click");
$(".removerCampo").bind("click", function () {
if($("tr.linhas").length > 1){
$(this).parent().parent().remove();
}
});
}
$(".adicionarCampo").click(function () {
novoCampo = $("tr.linhas:first").clone();
novoCampo.find('input[type="text"]').val("");
novoCampo.find('select').val("");
novoCampo.insertAfter("tr.linhas:last");
removeCampo();
});
});
</script>