salut tout le monde bah voila j'ai suivie le tuto sur les listes liées avec httprequest et j'ai essayé de le testé en l'adaptant a mes traitement sauf que j'ai pas les resutats attendus
voila ma page html :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 <div class="field"> <label> Année d'exercice</label> <select class="ui fluid dropdown" name="annee" id="annee" onchange="requestProjet(this);"> <option value="">Année d'exercice</option> <?php foreach($vue_exe as $looks_exe) { ?> <option value="<?php echo htmlspecialchars($looks_exe['EXE_CODE']); ?>" ><?php echo(htmlspecialchars($looks_exe['EXE_AN'])); ?> </option> <?php } ?> </select> <span id="loader"> <img src="../images/loader.gif"> </span> </div> <div class="field" > <label>Projet </label> <select class="ui fluid dropdown" name="projet" id="projet"> </select>
ensuite ma page list_projet.js:
et enfin ma page list_projet_by_id.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 function getXhr(){ var xhr = null ; if(window.XMLHttpRequest) xhr = new XMLHttpRequest ; else if(window.ActiveXObject) { try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } } else { alert('merde ton navigateur il trop chelou'); xhr = false ; } return xhr ; function requestProjet(oSelect){ var xhr = getXhr(); var value = oSelect.options[oSelect.selectedIndex].value; xhr.onreadystatechange = function() { if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)){ readData(xhr.responseXML); document.getElementById("loader").style.display = "none"; } else if (xhr.readyState < 4){ document.getElementById("loader").style.display = "inline" ; } xhr.open("POST", "list_projet_by_id.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("EXE_CODE" + value) ; } } function readData (oData){ var nodes = oData.getElementsByTagName("item"); var oSelect = document.getElementById("projet"); var oOption , oInner; oSelect.innerHTML = ""; for (var i=0, c=nodes.length; i<c; i++){ oOption = document.createElement("option"); oInner = document.createTextNode(nodes[i].getAttribute("name")); oOption.value = nodes[i].getAttribute("id"); oOption.appendChild(oInner); oSelect.appendChild(oOption); } }
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php header("Content-Type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; echo "<list>"; $exe = (isset($_POST["EXE_CODE"])) ? htmlentities($_POST["EXE_CODE"]) : NULL; if (isset($exe)) { try { require('../../model/kernel/kernel.php'); $projet = $base -> prepare("SELECT PRJ_CODE, PRJ_LIB FROM projet INNER JOIN exercice ON projet.EXE_CODE = exercice.EXE_CODE AND exercice.EXE_CODE = :exe "); $projet ->execute(array( 'exe' => $exe )) or die(print_r($projet->errorInfo())); $vue_projet = $projet -> fetchAll(); foreach($vue_projet as $looks_projet) { echo "<item id=\"" . $looks_projet["PRJ_CODE"] . "\" name=\"" . $looks_projet["PRJ_LIB"] . "\" />"; } } catch(exception $error) { die('erreur'.$error->getMessage()); } } echo("</list>"); ?>
quelqu'un pourrai m'aider svp je bloke
Partager