Excellent afternoon, I want to fill a hidden id="cdCliente" type input with the data of an option that is loaded from a database, could someone help me, regards
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-users"></i></span>
<select class="form-control" id="seleccionarCliente" name="seleccionarCliente" required>
<option value="">Seleccionar cliente</option>
<?php
$item = null;
$valor = null;
$categorias = ControladorClientes::ctrMostrarClientes($item, $valor);
foreach ($categorias as $key => $value) {
echo '<option value="'.$value["id"].'">'.$value["nombre"].'</option>';
}
?>
</select>
<input type="hidden" id="cdCliente" name="cdCliente" >
</div>
</div>
With
jQuery
it can be achieved in a very simple way. In the commented code I leave you a small instruction.