11548 sujets

JavaScript, DOM et API Web HTML5

Bonjour a tous, j'ai un petit problème avec mon formulaire, en effet j'ai deux select, mon premier sélect m'affiche une autre page, je récupère bien la valeur de la première liste déroulante grâce à ajax mais je souhaiterai récupérer la valeur de ma deuxième liste déroulante en meme temps mais je n'y arrive pas.

Ma première liste déroulante :

$reponse = mysql_query("SELECT id_entrepot, code_entrepot FROM cs_entrepot");
$ld = "<select name=\"liste_entrepot_source\" id=\"master_form-add2\" onchange=\"showTransfert(this.value)\" onclickclass=\"required\">";
$ld .= "<OPTION VALUE=0>Choisir un entrepot source</OPTION>";
// On boucle sur la table
while ($row = mysql_fetch_array($reponse)) 
{     
$id_s_m = $row["id_entrepot"];
$type_m = $row["code_entrepot"];
$ld .= "<OPTION VALUE='$id_s_m'>$type_m</OPTION>"; 
}
$ld .= "</SELECT>";


Ma deuxième liste déroulante

//Liste déroulante pour afficher les types de matériaux
$reponse = mysql_query("SELECT id_entrepot, code_entrepot FROM cs_entrepot");
$ld = "<select name=\"liste_entrepot_destinataire\" id=\"master_form-add2\"  onchange=\"showTransfert2(this.value)\" onclickclass=\"required\">";
$ld .= "<OPTION VALUE=0>Choisir un entrepot dest.</OPTION>";
// On boucle sur la table
while ($row = mysql_fetch_array($reponse)) 
{     
$id_d_m = $row["id_entrepot"];
$type_m = $row["code_entrepot"];
$ld .= "<OPTION VALUE='$id_d_m'>$type_m</OPTION>"; 
}
$ld .= "</SELECT>";



Mon script

function showTransfert(str)
{
if (str=="")
  {
  document.getElementById("master_adduser_cont_2").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("master_adduser_cont_2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","manage_t_stocks.php?q="+str,true);
xmlhttp.send();
}

function showTransfert2(str2)
{
xmlhttp.open("GET","manage_t_stocks.php?q2="+str2,true);
xmlhttp.send();
}


Merci pour votre aide
Modifié par flysse92 (19 Aug 2010 - 13:11)