1
Colleagues.
I have a code, which is not my own, which when registering the user click on a button Add more sizes and more fields appear. See:
So far all right, sizes and stocks go to the database. The problem is time to edit. I would like these fields to already appear "open" so I can include the information coming from the database. See the code:
<table border="0">
<tr class='linhas'>
<td style="padding: 5px"><input type="text" name="Tamanho[]" class="form-control" placeholder="Tamanho"></td>
<td style="padding: 5px"><input type="text" name="Estoque[]" class="form-control pull-left" placeholder="Estoque"></td>
<td style="padding: 5px"><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>
<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>
</table>
Jquery
<script type="text/javascript">
$(function () {
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").val("");
novoCampo.insertAfter("tr.linhas:last");
removeCampo();
});
});
</script>
This way you can’t answer your question, give more details. Which language are you using to make the connection to the bank? Do you already have the information in the view? What format is coming?
– JuniorNunes
Hello Junior. The problem is in jquery and not in PHP or Mysql. I need that when editing, appear the amount of fields related to the amount of registered information based on the post code.
– user24136
Yes, but how will you get how many items are registered and what information is due? Will this have to come from Mysql and PHP not? You are already bringing?
– JuniorNunes
That... I am, yes. I can bring the information from the database, all the fields of the form are already filled with the information, only these are missing...
– user24136
But we need to know how this information is coming, what is the name of the variable? what is the structure of the data? has as you "print" the value of this variable?
– JuniorNunes
Hello Junior. I managed to bring. I did inside the same PHP loop.
– user24136