voila ma premiere liste s'affiche mais quand je choisis dans cette liste la marque de voiture la 2 emme ne s'affiche pas
voila mon script
le fichier ajax.php
----------------------------------------------------------------------
<?php
switch($_REQUEST['param']) {
/** ******************************************************************************
* Generation de la liste des etats
*/
case 'modele':
$new_sql = 'SELECT ID_modele
FROM '.$data->modele.'
WHERE ID_marque = '.$_REQUEST['IDmarque'];
$modeleList = '<select size="1" onChange="sndReq(\'City\');" id="modeleList">';
$modeleList .= $data->liste_select('ID_modele', array('ID_modele'), $data->modele, 'id_modele', $ID_marque, false, '', $new_sql, false);
echo 'State|<br>'.$listeDepartement;
break;
}
?>
-------------------------------------------------------------------------
le fichier ajax.js
function createRequestObject()
{
var ro;
ro = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
return ro;
}
var http = createRequestObject();
function sndReq(param,arg,arg2)
{
IDmarque = GetIdmarque();
IDmodele = GetIdmodele();
http.open('get', 'ajax.php?param='+param+'&IDmarque='+IDmarque+'&IDmodele='+IDmodele);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse()
{
if(http.readyState == 4) {
var response = http.responseText;
var update = new Array();
if(response.indexOf('|') != -1) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
function GetIdCountry()
{
var ID_marque = document.getElementById('marqueList').options[document.getElementById('marqueList').selectedIndex].value;
return ID_marque;
}
function GetIdState()
{
var ID_modele = document.getElementById('modeleList').options[document.getElementById('modeleList').selectedIndex].value;
return ID_modele;
}
-------------------------------------------------------------------------
la page index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function getxhr()
{
var xhr=null;
if(window.xmlhttprequest)
xhr=new xmlhttprequest;
else
if(window.activexobject)
try{
xhr=new activexobject("msxl2.xmlhttp");
}
catch (e) {
xhr=new activexobject("microsoft.xmlhttp");
}
else {
alert("votre pas bon");
xhr=false;
}
return xhr;
}
function go()
{
var xhr=getxhr();
xhr.onreadystatechange= function() {
if(xhr.readystate==4 && xhr.status==200)
{
leselect=xhr.responseText;
document.getElementByld('modele').innerhtml=leselect;
}
xhr.open("POST","ajaxmodele.php",true);
xhr.setrequestheader('content-type','application/x-www-form-urlencoded');
sel= document.getElementByld('marque');
marque=sel.options[sel.selectindex].value;
xhr.send("marque="+marque);
}
//-->
</script>
</head>
<body>
<?php include('php\connection.php');
connectbd();
$result = mysql_query("SELECT * FROM marque");
?>
<table width="709" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="98" height="29"> </td>
<td width="524"> </td>
<td width="87"> </td>
</tr>
<tr>
<td height="280"></td>
<td valign="top">
<form>
<fieldset>
<label>marque</label>
<select name='marque' id='marque' onchange='go()' >
<option value='0'> tous </option>
<?php while($row = mysql_fetch_row($result)){?>
<option value="<? echo $row[0] ?>"> <? echo $row[0]?> </option>
<? }
?>
</select>
<label>modele</label>
<div id='modele' style='display:inline'>
<select name='modele' >
<option value='-1'>choisir une marque</option>
</select>
</div>
</fieldset>
</form></td>
<td></td>
</tr>
<tr>
<td height="17"></td>
<td></td>
<td></td>
</tr>
</table>
merci de bien vouloir me dire ou est le probleme
Partager