2
I’m trying to upload dynamic data from the comic book, but it doesn’t show up.
$(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--;
});
});
Exile of the RS
<?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 already in the form. The other fields are added using the JS above according to the need.
I don’t see where you’re getting data from the server/BD... (?) Why don’t you just make a clone of the line you want to duplicate, without having to go to the server? You can put the HTML of what you show in the image?
– Sergio
@Sergio Como assim clonar? I will post the code. Moment...
– Tiago
@Sergio put here http://jsfiddle.net/z0b1z7d6/ to improve the view.
– Tiago
Missing HTML where the duplicate button is...
– Sergio
This one. I’m using CSS. It’s the add-time1 ID
– Tiago
Updated http://jsfiddle.net/z0b1z7d6/2/ I put the CSS
– Tiago