I have a select that is dynamic, at the time of opening the page it performs its function but what I need is that when I open the page the default value is selected and I throw the images of the selected value, since it is annoying to open the page and not see anything until you select the value.
PHP:
include '../conexion.php';
$consulta = "SELECT * FROM mantras_productos ORDER BY tipo_producto ASC";
$query = mysqli_query($conexion,$consulta);
$producto.="<option value='0'>Selecciona Un Producto</option>";
while($f=mysqli_fetch_array($query,MYSQLI_ASSOC)){
$producto.= "<option value='".$f['id_producto']."'>".$f['tipo_producto']."</option>";
}
echo $producto;
Javascript:
$(nombreProdu());
function nombreProdu(busquedaProdu)
{
$.ajax({
url:'admin/phpadmin/selectProductos.php',
type: 'GET',
dataType:'html',
data : {busquedaProdu: busquedaProdu},
})
.done(function(result){
$("#cbx_carrito").html(result);
})
}
$(document).ready(function(){
$("#cbx_carrito").change(function () {
$("#cbx_carrito option:selected").each(function () {
id_producto = $(this).val();
$.get("php/carritoproductos.php", { id_producto: id_producto }, function(data){
$("#cargaCarrito").html(data);
});
});
})
});