<?php
// $Id: dynselectmodele.php,v 1.2 2006-06-07 10:05:59 fgiva Exp $
header('Content-type: text/html; charset=iso-8859-1');  
include ("../dyn/session.inc");
require_once "DB.php";
include_once ("../dyn/connexion.php");
$db=& DB :: connect($dsn, $db_option);
if (DB :: isError($db))
    die($db->getMessage());
$sql  = "select idmodele,libmodele from modeleelement where nature = '".$_POST["nature"]."' order by libmodele";
$res = $db->query($sql);
if (DB :: isError($res))
    die($res->getMessage().$sql);
echo 'var o = null;';
echo 'var s = document.forms["'.$_POST["form"].'"].elements["'.$_POST["select"].'"];';
echo 's.options.length = 0;';
echo 's.options[s.options.length] = new Option("Choisir un type","");';
while ($row=& $res->fetchRow()){
  $row[1]=str_replace("\"","\\\"",$row[1]); //pour " dans lib ecran
  echo 's.options[s.options.length] = new Option("'.$row[1].'","'.$row[0].'");';
}
$res->free();
$db->disconnect();
?>