Send to database - Add / Remove / JavaScript

1

Searching, I was able to find a script to create and remove fields.

Link Adding and Removing Javascript Fields

My question now is how to send this data to the database for future reference and display?

My version:

$(function () {
    var divContent = $('#formulario');
    var botaoAdicionar = $('a[data-id="1"]');
    var i = 1;

    //Ao clicar em adicionar ele cria uma linha com novos campos
    $(botaoAdicionar).click(function () {
        $('<div class="conteudoIndividual"><div class="row"><div class="col-xs-5"><div class="form-group" style="margin:0 0 0 1px;"><label class="control-label">Veículo</label><select name="veiculo[]" id="" class="form-control"><option value="S">Sim</option><option value="N">Não</option></select></div></div><div class="col-xs-2"><div class="form-group" style="margin:0 0 0 1px;"><label class="control-label">Valor</label><input name="veiculoValor[]" type="text" class="form-control" id="" value="" required></div></div></div><a href="#" class="linkRemover">- Remover Campos</a></div>').appendTo(divContent);
        $('#removehidden').remove();
        i++;
        $('<input type="hidden" name="quantidadeCampos" value="' + i + '" id="removehidden">').appendTo(divContent);
    });

    //Cliquando em remover a linha é eliminada
    $('#formulario').on('click', '.linkRemover', function () {
        $(this).parents('.conteudoIndividual').remove();
        i--;
    });
});
<a href="#" data-id="1" id="adicionarCampo">+ adicionar campo</a>

<form action="teste.php" method="post">
    <div id="formulario">
        <div class="row">
            <div class="col-xs-5">
                <div class="form-group" style="margin:0 0 0 1px;">
                <label class="control-label">Veículo</label>
                <select name="veiculo[]" id="" class="form-control">
                    <option value="S">Sim</option>
                    <option value="N">Não</option>
                </select>
                </div>
            </div>
            
            <div class="col-xs-2">
                <div class="form-group" style="margin:0 0 0 1px;">
                <label class="control-label">Valor</label>
                <input name="veiculoValor[]" type="text" class="form-control" id="" value="" required>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" name="MM_insert" value="form1">
    <input type="submit" value="Gerar Código" />
</form>
    
asked by anonymous 08.05.2015 / 18:13

0 answers