j'ai un fichier html qui se remplit avec les données d'un xml par l'intérmédiaire d'une fonction javascript.
je voudrais que la couleur de l'element n°7
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 <div style="text-align: left;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"> <html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>"> <head> <title>Historique</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <script language="JavaScript"> AfficheDocXML(); function AfficheDocXML() { var Document; Document = new ActiveXObject("Microsoft.XMLDOM"); Document.async = "false"; var couleur; if(Document.load("data.xml")) { document.write("<TABLE BORDER=1 CELLPADDING=0>"); for(i=1;i<Document.documentElement.childNodes.length;i++) { document.write ("<TR ALIGN=center>"); for(j=0;j<= 7;j++) { document.write ("<TD>"); if (j != 6) document.write (Document.documentElement.childNodes(i).childNodes(j).text); if (j == 6) { couleur = Document.documentElement.childNodes(i).childNodes(6).text; //alert(Document.documentElement.childNodes(i).childNodes(6).text); document.write (Document.documentElement.childNodes(i).childNodes(7).style.color = couleur); } document.write ("</TD>"); } document.write ("</TR>"); } document.write ("</TABLE>"); } else {alert("fichier pas trouvé !");} } </script> </head> <body> </body> </html> </div>
prendre une certaine couleur en fonction de sa valeur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Document.documentElement.childNodes(i).childNodes(7).style.color = couleur
lorsque j'execute le script, j'ai l'erreur:
est ce que quelqu'un pourrait m'expliquer pourquoi???
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <div style="text-align: left;">documentElement.childNodes(...).childNodes(...).style a la valeur null ou n'est pas un objet</div>
votre aide serait vraiment, vraiment, vraiment tres précieuse.
Partager