Bonjour à tous,
je débute en xsl et xml (et javascript)
j'affiche dans un html résultant un tableau avec un combo proposant de trier suivant quelques champs.
Lors de la sélection d'un champs dans le combo, j'appelle une fonction JavaScript qui éxecute correctement le tri.
mon seul problème est que je perds la sélection du combo, car la page est rechargée après l'appel de la fonction de tri...
ci-dessous mon xsl et xml, quelqu'un aurait-il une solution ? j'approche du but... mais il reste ce petit problème !

mon xsl :
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
 <head>
 <title>Listing VO</title>
 <script language="JScript"><![CDATA[
 
 // Déclaration des variables
 var XSLSource = new Object();          
 var XMLSource = new Object();
 
 // Chargement des documents XML et XSL
 XMLSource = document.XMLDocument;
 XSLSource = document.XSLDocument;
 
 function tri (rubrique) {
 
  // Déclaration des variables
 var XSLSort = new  Object();            
 
 // Sélection de l'ordre xsl:sort
 XSLSort =
   XSLSource.documentElement.selectNodes("//xsl:sort");
 
  // Affectation de la rubrique de tri
 if (XSLSort[0].attributes(0).text == rubrique.toString()){
   if ( XSLSort[0].attributes(1).text == "ascending") {
     XSLSort[0].attributes(1).text = "descending";
   } else {
     XSLSort[0].attributes(1).text = "ascending";
   }
 } else {
   XSLSort[0].attributes(1).text = "ascending";
 }
 XSLSort[0].attributes(0).text = rubrique.toString();
 // affichage de l'ordre de tri
 XSLem = XSLSource.documentElement.selectNodes("//p/em");
 XSLem [0].text = rubrique.toString();
 XSLem [1].text = XSLSort[0].attributes(1).text ;
 // Réaffichage de la page
 document.body.innerHTML =
   XMLSource.transformNode(XSLSource);
}]]></script>
 </head>
 <body>
   <p>Tri sur <em>NUMERO</em> par ordre <em>descending</em>.</p>
   <p>Cliquez sur un titre pour changer l'ordre de tri.</p>
   <table>
      <tr>
        <th align="left">Trier selon
          <select onChange="tri(this.options[this.selectedIndex].value);">
          <option value="MARQUE">
          	par marque
          </option>
          <option value="MODELE" selected="selected">
          	par modèle
          </option>  
          <option value="DATE_IMMAT">
          	par date d'immatriculation
          </option>                    
          </select>
        </th>
      </tr>   
   </table>
   <table border="1" cellspacing="1">
     <tr>
       <th id="HeaderColumnNUMERO"
         onclick="javascript:tri('NUMERO');">Numéro</th>
       <th id="HeaderColumnMARQUE"
         onclick="javascript:tri('MARQUE');">Marque</th>
       <th id="HeaderColumnMODELE"
         onclick="javascript:tri('MODELE');">Modèle</th>
       <th id="HeaderColumnIMMATRICULATION"
         onclick="javascript:tri('IMMATRICULATION');"
         >Immatriculation</th>
       <th id="HeaderColumnDATE_IMMAT"
         onclick="javascript:tri('DATE_IMMAT');"
         >Date d'immatriculation</th>
     </tr>
     <xsl:apply-templates select="VEHICULES/VEHICULE">
       <xsl:sort select="NUMERO" order="descending"/>
     </xsl:apply-templates>
   </table>
 </body>
</html>
</xsl:template>
<xsl:template match="VEHICULE">
 <tr>
   <td>
     <xsl:value-of select="NUMERO"/>
   </td>
   <td>
     <xsl:value-of select="MARQUE"/>
   </td>
   <td>
     <xsl:value-of select="MODELE"/>
   </td>
   <td>
     <xsl:value-of select="IMMATRICULATION"/>
   </td>
   <td>
     <xsl:value-of select="DATE_IMMAT"/>
   </td>
 </tr>
</xsl:template>
</xsl:stylesheet>
mon xml :
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
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml:stylesheet type="text/xsl" href="tri.xsl"?>
<VEHICULES>
      <VEHICULE>
            <NUMERO>000066</NUMERO>
            <MARQUE>Daewoo</MARQUE>
            <MODELE>Lanos SE GPL</MODELE>
            <IMMATRICULATION>9999 ZZ 99</IMMATRICULATION>
            <DATE_IMMAT>1999-11-01</DATE_IMMAT>
      </VEHICULE>
      <VEHICULE>
            <NUMERO>000180</NUMERO>
            <MARQUE>Daewoo</MARQUE>
            <MODELE>Lanos SE GPL</MODELE>
            <IMMATRICULATION>7777 XX 99</IMMATRICULATION>
            <DATE_IMMAT>1999-10-01</DATE_IMMAT>
      </VEHICULE>
      <VEHICULE>
            <NUMERO>000280</NUMERO>
            <MARQUE>Daewoo</MARQUE>
            <MODELE>Lanos SE GPL</MODELE>
            <IMMATRICULATION>8888 XX 99</IMMATRICULATION>
            <DATE_IMMAT>2000-10-01</DATE_IMMAT>
      </VEHICULE>
</VEHICULES>