My problem is that I do not know how to capture the selected data from the combobox list, I do not mean the value 1,2,3,4 I mean what the combo shows, in my case team names, the data I bring them with js, and I insert the numeric value that I selected from the list, and that's fine, but I also need to get and insert the team name, not just the value.
From here I extract the data, filtered by a department id.
$query = $conexion->query("SELECT * FROM equipos WHERE idDepto = $depto");
echo '<option value="0">Seleccione</option>';
while ($row = $query->fetch_assoc()) {
echo '<option value="' . $row['idEquipo'] . '">' . $row['Nombre'] .
'</option>' . "\n";
}
With this function Js I pass them to HTML, where in HTML I only take "cmbequipos".
$(function(){
// Lista de Deptos
$.post( 'departamentos.php' ).done( function(respuesta)
{
$( '#cmbdeptos' ).html( respuesta );
});
// lista de Deptos
$('#cmbdeptos').change(function()
{
var el_continente = $(this).val();
// Lista de Eqs
$.post( 'equipos.php', { continente: el_continente} ).done( function( respuesta )
{
$( '#cmbequipos' ).html( respuesta );
});
});
// Lista de Equipos
$( '#cmbequipos' ).change( function()
{
var pais = $(this).children('option:selected').html();
});
})
HTML Vista
<select name="cmbequipos" class="form-control input-sm" required="Yes"
id="cmbequipos" <?php echo $_SESSION["status"]; ?>>
</select>
At the moment of inserting I put something like that $var = $_POST['cmbequipos'];
but I insert the value in this case the id of the Team. But I try to take the name instead of the value.