<?php
// $Id: dynselectutilisateur.php,v 1.3 2007-05-11 14:02:19 fgiva Exp $
header('Content-type: text/html; charset=iso-8859-1');  
include ("../dyn/session.inc");
require_once "DB.php";
include_once ("../dyn/connexion.php");
echo 'var o = null;';   
echo 'var s3 = document.forms["'.$_POST["form"].'"].elements["'.$_POST["select"].'"];';
echo 's3.options.length = 0;';
if ($_POST["nom"]<>"") {
  $db=& DB :: connect($dsn, $db_option);
  if (DB :: isError($db)) 
      die($db->getMessage());
  $sql  = "select idutilisateur,concat(nom,' ',prenom) from personnel where upper(concat(nom,' ',prenom)) like upper('".$_POST["nom"]."%') order by nom, prenom";   
  $res = $db->query($sql);
  if (DB :: isError($res))
      die($res->getMessage().$sql);
  while ($row=& $res->fetchRow())
    echo 's3.options[s3.options.length] = new Option("'.$row[1].'","'.$row[0].'");';
  $res->free();
  $db->disconnect();
}
echo 'if (s3.options.length == 0) {';
echo 's3.options[0] = new Option("",0);';
echo 's3.style.visibility = "hidden";';
echo '} else ';
echo 's3.style.visibility = "visible";';
echo 's3.options[0].selected = true;';
?>