我想在选择列表中选择一个选项并将代码触发到更改功能中。
PHP请求代码:
$la_reservation = $dbh->prepare("SELECT *,
Date_debut, Date_fin,
client.Nom_societe, Personne_de_contact_idPersonne_de_contact,
IdAdresse, adresse.Rue, adresse.Numero, adresse.Boite, adresse.Code_postal, adresse.Localite, adresse.Pays, adresse.Email, Tel1, adresse.Client_IdClient
FROM bail
LEFT JOIN reservation ON idBail = Ref_bail
LEFT JOIN client ON bail.Ref_filiale = client.IdClient
LEFT JOIN personne_de_contact ON Personne_de_contact_idPersonne_de_contact = idPersonne_de_contact
LEFT JOIN adresse ON adresse.Client_IdClient = client.IdClient
WHERE idBail = :num_reservation");
$data = array(":num_reservation"=>$_GET['num_res']);
//echo str_replace(array_keys($data), array_values($data), $la_reservation->queryString);
$la_reservation->execute($data);
$res = $la_reservation->fetch();
我使用 $res['IdClient'] 来指示我想在选择列表中选择哪个选项:
<script>$('#liste_clients').val("<?php echo $res['IdClient']?>");</script>
生成的代码是:
<script>$('#liste_clients').val("14");</script>
但是更改功能中的警报不起作用:
$("#liste_clients").change(function(){
alert("here");
....
}