I want to save the data of the inputs in an array, and by pressing the boton
agregar
put them in a table and so x
number of data you want to add, once you have the entire list that when you press boton de Guardar datos
send that array with all the data in the list, using ajax, jQuery
,
I hope you can help me
var parametros=[];
var parame=[];
var par=[];
$("#datos div input, #datos div input:checked, #datos div select").each(function(i,e){
var value ="";
parametro = {
"ckpID" : $(this).val()
};
parametros.push(parametro);
});
par.push(parametros)
console.log(par);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group" id="datos">
<div class="form-group col-md-12">
<div class="form-group col-md-2">
<label>Existe:</label><br>
<input type="checkbox" checked="true">
</div>
<div class="form-group col-md-3">
<label>Nombre:</label><br>
<input type="text" class="form-control">
<select id="elemento" class="form-control requerido">
<option value="1">Dato 1</option>
<option value="2">Dato 2</option>
<option value="3">Dato 3</option>
<option value="4">Dato 4</option>
</select>
</div>
<div class="form-group col-md-3">
<label>Cantidad:</label><br>
<input type="number" class="form-control">
</div>
<div class="form-group col-md-2">
<label for="sol_esUnidad">Es nuevo:</label><br>
<input type="checkbox" checked="true">
</div>
<div class="form-group col-md-2">
<label>Adquirido:</label><br>
<input type="number" class="form-control">
</div>
<div class="form-group col-md-2">
<label>Prestado:</label><br>
<input type="checkbox" checked="true">
</div>
</div>
</div>
<button type="button" class="btn btn-primary pull-left btn-tabla-nuevo">
<span class="glyphicon glyphicon-plus"></span> Agregar
</button>
<div class="form-group">
<table id="datostabla" class="table"><thead><tr><th>Existe </th><th>Nombre</th><th>Cantidad</th><th>Es nuevo</th><th>Adquirio</th><th>Prestado</th></thead></table>
</div>
<button type="button" class="btn btn-primary pull-left btn-tabla-nuevo">
<span class="glyphicon glyphicon-plus"></span> Guardar Datos
</button>