I have inserted a select of a php with ajax in another php that is the index. This is the index of where I take the data.
<?php
include 'conexion.php';
$msg ="";
$tipo= $_POST['tipo']??"";
$sql = "SELECT marca.idmarca as id,marca.marca as marca
from marca, producto, modelo
where producto.modelo = modelo.idmodelo
and modelo.marca = marca.idmarca
and producto.tipo = '$tipo'";
$consulta = $conn->query($sql);
$msg .= "<select id=\"marc\">";
$msg .= "<option value=\"\">Selecciona una marca</option>";
while($fila = $consulta->fetch()){
$msg .= "<option value=\"".$fila['id']."\">".$fila['marca']."</option>";
}
$msg .= "</select>";
echo $msg;
?>
And picking up the id of the select in the jquery does not do anything to me. The jquery link is in the index.php.
//Codigo jquery
$("#marc").change(function(){
var tipo = $(this).val();
alert(tipo);
});