-2
I am having difficulty in obtaining the values of JSON I consult from my stock, after consulting it and filling in my inputs I filled in some more fields manually and soon after registering this whole set in another bank. The problem is when I register these inputs that fills with JSON, because they appear to be empty in PHP, but the input view is OK.
$(document).ready(function(){
$("input[name='codProduto[]']").blur(function(){
     var nomeProduto = $("input[name='nomeProduto[]']");
     var qtProduto = $("input[name='qtProduto[]']");
     var valorProduto = $("input[name='valorProduto[]']");
     $( nomeProduto ).val('Carregando...');
     $( qtProduto ).val('Carregando...');
     $( valorProduto ).val('Carregando...');
         $.getJSON(
             'function.php',
             { codProduto: $( this ).val() },
             function( json ) 
             {
                  $( nomeProduto ).val( json.nomeProduto );
                  $( qtProduto ).val("1");
                  $( valorProduto ).val( json.valorProduto);
             }
         );
 });
 });
Stretch with inputs
     <form id="form1" name"form1" method"post" action"" enctype="multipart/form-data">
        <div class="produtos">
          <p class="campoProduto">
          <label>Cód Produto: <input type="text" name="codProduto[]" id="codProduto[]" size="5"/></label>
          <label>Produto: <input name="nomeProduto[]" type="text" size="10" value="" /></label> 
          <label>Qt.:  <input type="number" min="1" max="999" size="1" name="qtProduto[]" id="qtProduto[]" onblur="calcValor()" /></label>
          <label>Valor R$: <input type="text" name="valorProduto[]" id="valorProduto[]" size="6" onkeypress="mascara(this,float)"/></label>
          <a href="#" class="removerProduto">Remover Produto</a> 
               </p>
             </div>
             <p>
              <a href="#" class="adicionarProduto">Adicionar Produto</a>
            </p>
            <br>
          <label>Data da Compra <input name="datacompra" type="text" id="datacompra" size="6" maxlength="10" value="<?php echo date('d/m/Y')?>" onKeyUp="javascript:somente_numero(this);" onkeypress="formatar_mascara(this,'##/##/####')"/></label>
   <label>Desconto (%)<span style="display:none" id="sp_vdesconto"></span><input type="hidden"  name="vdesconto" id="vdesconto" />:<input type="text" name="desconto" size="6" value="0"id="desconto" onblur="calcValor()" /></label>   
   <label>Entrada R$<span style="display:none" id="sp_vdentrada"></span><input type="hidden" size="6" name="vdentrada" id="vdentrada" />:<input type="text" name="entrada" size="6" value="0"id="entrada" onblur="calcValor()" /></label> 
   <label>Pacelas:  <input type="number" min="1" max="6" size="1" value="1" name="parcelas" maxlength="2" size="2" id="parcelas"/></label>  
   <label>Valor Total: <input type="text" name="total" size="6" id="total" /></label> 
               <input type="reset">
             <input type="hidden" name="cadastra" value="add" />
             <input type="submit" name="add" id="add" value="  Cadastrar  " />  
       </form>
and the time of entry into the database:
<?php   if (isset($_GET['cadastra']) && $_GET['cadastra'] == 'add') {
  $datacompra = implode("-", array_reverse(explode("/",$_GET['datacompra'])));
  $nomeProduto = $_GET['nomeProduto[]'];
  $qtProduto = $_GET['qtProduto[]'];
  $valorProduto = $_GET['valorProduto[]'];
  $pagamento = "CREDIARIO";
  $ficha = $_GET['cadastro'];
        $cadastra = mysql_query("INSERT INTO t_cadcontratos (Ficha, NumContrato,DataContrato, QuantParcelas, ValorContrato, Entrada, Saldo, DescricaoProduto, QuantProdutos, FormaPagamento) 
                            VALUES ('$ficha', '$datacompra', ('$_GET[parcelas]'), '$valorProduto', ('$_GET[entrada]'), ('$_GET[total]'),
                            UPPER('$nomeProduto'), ('$qtProduto'), '$pagamento')");
    if($cadastra == '1') {
        echo "Venda CREDIARIO realizada com sucesso !";
    }else{
        echo "Erro ao realizar a venda CREDIARIO, tente novamente !";
}
}
?>
Here is an excerpt from the . js file I use to add and remove inputs for new products:
$(function () {
    function removeProduto() {
        $(".removerProduto").unbind("click");
        $(".removerProduto").bind("click", function () {
            i=0;
            $(".produtos p.campoProduto").each(function () {
                i++;
            });
            if (i>1) {
                $(this).parent().remove();
            }
        });
    }
    removeProduto();
    $(".adicionarProduto").click(function () {
        novoCampo = $(".produtos p.campoProduto:first").clone();
        novoCampo.find("input").val("");
        novoCampo.insertAfter(".produtos p.campoProduto:last");
        removeProduto();
    });
});
The mistake:

Can you help me?
In php you need to put bracket in the key name, you should make a
foreachto get all the ex values:foreach($_GET['nomeProduto'] as $item){....}remember to check that $_GET is not empty.– rray
Right, the problem I solve by taking the colquetes and using to fetch the value "filter_input", until then ok, but I need to use a certain array because as seen in the code above I will add more products in time and after inserting itlos no banco também, ie I will have an array of products that I will then need to stock or add... Do you have any idea how I can do this control with JSON and after using in PHP/BD? waiting and thank you! above insert the snippet that adds and removes new inputs for each product.
– Rafael Assmann