hello friends I have a .js file which allows me to add dynamic rows and it works perfectly, but my problem arises that I am now using 1 input and 2 dynamic select that load values from the database, as I would have to do add those two select in the .js file, since it has never touched me in that way, but as the saying goes there is always a first time.
this is my file.js which works perfectly but only with input
var inputs = 3;
$(document).ready(function(e) {
$('#agregar').on('click', function() {
if (inputs == 6) {
return false;
}
inputs = inputs + 1;
if ($('#alumno' + inputs + '').length > 0) {
$('#alumno' + inputs + '').show();
} else {
$('.inputs').append('<div id="alumno'+inputs+'"><div class="input-field col s12 m4"><input id="cedula" type="text" name="cedula[]" autocomplete="off" title="Cedula!" required/><label for="cedula">Cédula:</label></div><div class="input-field col s12 m4"><input id="nombres" type="text" name="nombres" autocomplete="off" title="Nombres!" required/><label for="nombres">Nombres:</label></div><div class="input-field col s12 m4"><input id="apellidos" type="text" name="apellidos" autocomplete="off" title="Apellidos!" required/><label for="nombres">Apellidos:</label></div></div>');
}
$('#quitar').fadeIn();
if (inputs == 6) {
$('#agregar').fadeOut();
}
});
$('#quitar').on('click', function() {
if (inputs == 3) {
return false;
}
$('#alumno' + inputs + '').hide();
inputs = inputs - 1;
$('#agregar').fadeIn();
if (inputs == 3) {
$('#quitar').fadeOut();
}
});
});
these are the two selections that I want to add in the .js file
<div class="input-field col s12 m4">
<select name="id_cuentas" id="id_cuentas" required/>
<option value="" disabled selected>Tipo de Cuenta:</option>
<?php
$consulta = $DB_con->query("SELECT * FROM cuentas ORDER BY id_cuentas");
while ($linea = $consulta->fetch(PDO::FETCH_ASSOC)) {
?>
<option value="<?php echo $linea['id_cuentas[]'] ;?>"><?php echo
$linea['cuentas'] ;?></option>
<?php
}
?>
</select>
</div>
<div class="input-field col s12 m4">
<select name="id_bancos" id="id_bancos" required/>
<option value="" disabled selected>Banco Destino:</option>
<?php
$consulta = $DB_con->query("SELECT * FROM bancos ORDER BY id_bancos");
while ($linea = $consulta->fetch(PDO::FETCH_ASSOC)) {
?>
<option value="<?php echo $linea['id_bancos[]'] ;?>"><?php echo $linea['bancos'] ;?></option>
<?php
}
?>
</select>
</div>