salut je suis debutant en ajax surtout recuperer les données extrait d'un fichier Xml
je cite mon bleme c'est que j'ai un formulaire et un tableau dynamique
j'ai deux lien ( suppression et modification) a chaque ligne de mon tableau je veux que utilisateur clique sur lien modification il dois chercher d'abord quel Id ainsi récupérer l'enregistrement d'après un fichiers xml dynamique
voila ce que j'ai pu faire pour le moment
exemple de mon fichiers xml
une partie de ma page.html
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <?xml version="1.0" encoding="iso-8859-1"?> <root> <gestion> <ID>1</ID><nom>rochdi</nom><Prenom>mehdi</Prenom><age>26</age><photo>mehdi-identification.jpg</photo><adresse>lot sim bv dakhla rue 23</adresse><telephone>0527071817</telephone><mail>soopranoo@hotmail.fr</mail><choix1>choix1</choix1><choix2>choix2</choix2><choix3>choix3</choix3><choix>3</choix><note>bla bla bla</note> etc... ... .. </gestion> </root>
le problème ce qu'il m'affiche juste le prenom svp aider moi sur ca
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
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 </style> <script language="JavaScript"> function processData(doc) { document.monForm.nom.value= doc.getElementsByTagName('nom').item(0).firstChild.data; document.monForm.prenom.value= doc.getElementsByTagName('prenom').item(0).firstChild.data; document.monForm.age.value= doc.getElementsByTagName('age').item(0).firstChild.data; document.monForm.adr.value= doc.getElementsByTagName('adr').item(0).firstChild.data; document.monForm.tel.value= doc.getElementsByTagName('tel').item(0).firstChild.data; document.monForm.mail.value= doc.getElementsByTagName('mail').item(0).firstChild.data; document.monForm.note.value= doc.getElementsByTagName('note').item(0).firstChild.data; } function submitForm() { var xhr=null; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("GET", "xml/f-xml.xml",true); xhr.onreadystatechange = function() { processData(xhr.responseXML); } xhr.send(null); } </script> <form name="monForm" id="monForm "action="acce-admin.php?choix=ecriture-ajout" enctype="multipart/form-data" method="post" onSubmit="return control();" > <label>nom</label> <input name="nom" type="text" class="inputFORPMULAIRE" id="nom" /> <label>Prenom</label> <input name="prenom" id="prenom" type="text" class="inputFORPMULAIRE"> <label>Age</label> <input name="age" id="age" type="text" class="inputFORPMULAIRE" /> <input name="valider" type="submit" class="form_bouton" value="Valider" onClick="control();" /> <table width="1270" cellspacing="1" class="tablesorter"> <thead> <tr> <th colspan="2"> </th> <th>Nom</th> <th width="7%">Prenom</th> <th width="3%">Age</th> </tr> </thead> <tbody> <?php include 'connexion.php'; $sql="SELECT * from inscription"; $req=mysql_query($sql) or die("erreur en sql". mysql_error()); while($l=mysql_fetch_array($req)){ ?> <tr> <td width="3%" height="21"><a href="#" onclick="submitForm(); return false">Modification</a></td> <td width="2%"><a href="#">sup</a></td> <td width="5%"><?php print($l['nom']); ?></td> <td><?php print($l['prenom']); ?></td> <td><?php print($l['age']); ?></td> </tr> <?php } ?> </tbody> </table>
Partager