I'm trying to load dynamic data from DB, but it does not appear.
$(function () {
var divContent = $('#formularioVeiculo');
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 id="formularioVeiculo"><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"><?php do { ?><option value="<?php echo $row_rsVeiculo['ID_Veiculo']; ?>"><?php echo $row_rsVeiculo['placa']; ?> - <?php echo $row_rsVeiculo['tipo']; ?></option><?php } while ($row_rsVeiculo = mysql_fetch_assoc($rsVeiculo)); ?></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 class="col-xs-5"><div class="form-group"><button class="btn btn-danger btn-xs linkRemover" style="margin:35px 0 0 0"><i class="fa fa-times bigger-110 icon-only"></i></button></div></div></div></div></div>').appendTo(divContent);
$('#removehidden').remove();
i++;
$('<input type="hidden" name="quantidadeCampos" value="' + i + '" id="removehidden">').appendTo(divContent);
});
//Cliquando em remover a linha é eliminada
$('#formularioVeiculo').on('click', '.linkRemover', function () {
$(this).parents('.conteudoIndividual').remove();
i--;
});
});
RS Layout
<?php do { ?><option value="<?php echo $row_rsVeiculo['ID_Veiculo']; ?>"><?php echo $row_rsVeiculo['placa']; ?> - <?php echo $row_rsVeiculo['tipo']; ?></option><?php } while ($row_rsVeiculo = mysql_fetch_assoc($rsVeiculo)); ?>
Image of the result. The first field appears because it is already in the form. The remaining fields are added using the above JS as needed.