I have a select that I load with the data that I bring from my BD, I have a javascritp function to which I send as a parameter the element of the list that I select, but then in the function I make an alert to show what arrives but it always arrives empty. I do not see anything in the alert.
PHP and HTML code
<select class="custom-select form-control" id="tipo" onchange="cargarCategoria(this)">
<option selected></option>
<?php
require ('conexion/Conexion.php');
$query = "SELECT DISTINCT tipo FROM formacion";
$result = mysqli_query($con,$query);
while($fila = mysqli_fetch_array($result))
{
echo '<option value="">'.$fila["tipo"].'</option>';
}
?>
</select>
JavaScript code
function cargarCategoria(dato)
{
alert(dato.value);//Este es el valor que llega vacio, deberia ser el elemento seleccionado del select.
$.ajax({
type: "POST",
url: 'consultas/consultarCategoria.php',
data: 'tipo='+dato,
success: function(resp){
$('#categoria').html(resp);
}
});
}