a greeting.
I can't find a way to send two variables at the same time through JavaScript and PHP.
Currently my code works by sending a variable.
This is the input.
<tr>
<?php
require ('conexespecial/selectconex.php');
$query = "SELECT DISTINCT flota FROM para_equipo WHERE cliente='$acliente' ORDER BY flota";
$resultado=$mysqli->query($query);
?>
<td><font color="#000">Flota:</font></td>
<td><select name="cbx_estado" id="cbx_estado" class="camp" required >
<option></option>
<?php while($row = $resultado->fetch_assoc()) { ?>
<option value="<?php echo $row['flota']; ?>"><?php echo $row['flota']; ?></option>
<?php } ?>
<!--ADICIONAL A LA VARIABLE QUE YA ESTOY ENVIANDO AL SELECCIONAR EL SELECT TAMBIEN ESTOY BUSCANDO ENVIAR LA VARIABLE DE $acliente-->
<input type="hidden" name="clientec" value="<?php echo $acliente;?>" readonly="readonly">
</select>
</td>
</tr>
This is the JavaScript where I don't know how to send a second variable at the same time as the select.
$(document).ready(function(){
$("#cbx_estado").change(function () {
$('#cbx_localidad').find('option').remove().end().append('<option value="whatever"></option>').val('whatever');
$("#cbx_estado option:selected").each(function () {
flota = $(this).val();
$.post("conexespecial/getMunicipio.php", { flota: flota }, function(data){
$("#cbx_municipio").html(data);
});
});
})
});
And this is where I receive the variable:
<?php
require ('selectconex.php');
$flota = $_POST['flota'];
$clientec = $_POST['clientec'];
$queryM = "SELECT DISTINCT nro_equipo FROM para_equipo WHERE flota = '$flota' AND cliente='$clientec' ORDER BY nro_equipo";
$resultadoM = $mysqli->query($queryM);
$html= "<option></option>";
while($rowM = $resultadoM->fetch_assoc())
{
$html.= "<option value='".$rowM['nro_equipo']."'>".$rowM['nro_equipo']."</option>";
}
echo $html;
?>
Any help you can give me can be very useful, thank you very much.
I think this can fix you. To the input hidden add an ID or a CLASS
and here add it to extract its value
and here you add it in the parameter so that it is added in the post