1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<?php session_start();
function AfficherCodes($poles_id)
{
$reponse = new xajaxResponse();
$liste_codes = '<select name="pro_codes" size="5" multiple>';
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $bdd = new PDO('mysql:host=localhost;dbname=db_test', 'root', '', $pdo_options);
$reponse_qr = $bdd->query('SELECT * FROM codes WHERE poles_id = "'.$poles_id.'"');
while($data = $reponse_qr->fetch())
{
$liste_codes .= '<option value="'.$data['codes_id'].'">'.$data['codes_nom'].' - '.$data['codes_titre'].'</option>';
}
$reponse_qr->closeCursor();
$liste_codes .= '</select>';
$reponse->assign('block_liste_codes', 'innerHTML', $liste_codes);
return $reponse;
}
require ('/app/htdocs/intranet/xajax/xajax_core/xajax.inc.php');
$xajax = new xajax(); //On initialise l'objet xajax.
$xajax->register(XAJAX_FUNCTION, 'AfficherCodes');// On enregistre nos fonctions.
$xajax->processRequest();
echo'<form>
<select id="choix_poles" name="poles_id" class="champform_liste" onChange="xajax_AfficherCodes(this.value)"><option value="0"></option>
';
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $bdd = new PDO('mysql:host=localhost;dbname=db_test', 'root', '', $pdo_options);
$reponse = $bdd->query('SELECT * FROM poles');
while ($data = $reponse->fetch())
{
echo '<option value="'.$data['poles_id'].'">'.$data['poles_nom'].'</option>';
}
$reponse->closeCursor();
echo'
<option value="FT_PAPC">Fonctions</option></select>
';
$xajax->printJavascript('../../../xajax/');
echo'
<script type="text/javascript">
function refresh()
{
xajax_AfficherCodes();
setTimeout(refresh, 5000);
}
</script>
<div id="block_liste_codes"></div></form>
';
?> |
Partager