quelle est l'erreur dans ce code ?
ma liste ne se rempli pas, en fait le "toto" s'affiche mais pas le "titi" (ajaxLivre2), voila le code maintenant :
première page (auteurs2):
Code:
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
<?php
include("_session.php");
if(!$editDev)
exit("Forbidden!");
if(!$userId)
{
header("Location: login.php");
exit();
}
$CurrentPage="admin";
$db=Db_ConnectToProduct("vhd");
$ReqNbMod="SELECT count( DISTINCT `moId` ) as nbmod FROM `Model` ";
$ResNbMod=Db_Query($ReqNbMod,$db);
$maxMod = Db_GetArray($ResNbMod);
?>
<html>
<head>
<title>validation croisée </title>
<SCRIPT language="JavaScript" type='text/javascript'>
function getXHR()
{ var newReq = null;
if(window.XMLHttpRequest)
{
try
{
newReq = new XMLHttpRequest();
} catch(e)
{
newReq = false;
}
}
else if(window.ActiveXObject)
{
try
{
newReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e)
{
try
{
newReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e)
{
newReq = false;
}
}
} return newReq;
}
function loadXHR(url,methode,id)
{
var req = getXHR();
req_global = req;
req.open(methode,url,true);
req.send(null);
req.onreadystatechange = function()
{
if (req.readyState == 4)
{
rhttp = req.responseText;
if(document.getElementById(id))
document.getElementById(id).innerHTML = rhttp;
}
}
}
</SCRIPT>
</head>
<body>
<form name = "form" method="post" action="ajaxLivre2.php">
Model : <?php echo $maxMod["nbmod"]; ?>
<select name="SmodId" id="SidmoId" onChange="loadXHR('ajaxLivre2.php?mold='+this.options[this.selectedIndex].value,'GET','idmseId')">
<option> selectionner qqch</option>
<?php
$query="SELECT moId,moName FROM Model ORDER BY moName ASC";
$req=Db_Query($query,$db);
while($row=Db_GetArray($req))
{
$selected=($row["moId"]==$moId)?" selected=\"selected\"":"";
echo $selectModel="<option value=\"".$row["moId"]."\"".$selected.">".$row["moName"]."</option>\n";
}
?>
</select>
<div id="idmseId">
</div>
</form>
</body>
</html> |
et la deuxième (ajaxLivre2) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<?php
echo "toto";
echo "<select name='mseId'>";
echo "titi";
if(isset($_POST["SidmoId"]))
{
$query="SELECT mseId,mseName FROM ModelSet ";
$query .= " WHERE msemoId = " .$_POST["SidmoId"] ;
$query .= " ORDER BY mseName ASC ;" ;
$req=Db_Query($query,$db);
echo $query;
while($row=Db_GetArray($req))
{
$selected=($row["mseId"]==$mseId)?" selected=\"selected\"":"";
echo $selectSet="<option value=\"".$row["mseId"]."\"".$selected.">".$row["mseName"]."</option> ";
}
}
echo "</select>";
?> |