déjà 5h que je me casse la tête dessus et impossible de trouvé le problème.

profil.html :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
<html>
<head>
<link rel='stylesheet' type='text/css' href='profil.css' />
<script type='text/JavaScript' src='profil.js'></script>
</head>
<body>
<div id='contents_profil'></div>
</body>
</html>
profil.css

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
.champs{
	position: relative;
	float: left;
	width: 50%;
	color: #000000;
	text-align: right;
	font-weight: bold;
}
.value{
	position: relative;
	float: left;
	width: 50%;
	color: #004488;
}
.item{
	position: relative;
	height: 25px;
	width: 300px;
	padding: 0px;
	margin: 4px;
	font-size: 12;
	font-family: verdana;
}
profil.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
<?xml version="1.0" encoding="iso-8859-1" ?>
<profil>
	<couple>
		<champs>Nom</champs>
		<value>Moncond'huy</value>
	</couple>
	<couple>
		<champs>Prenom</champs>
		<value>Arnaud</value>
	</couple>
	<couple>
		<champs>Ville</champs>
		<value>Forges-les-Eaux</value>
	</couple>
</profil>
profil.js

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
window.onload = function profilXML()
{
 
var xhr_object = "";
var arrayMessage = new Array();
var text = "";
var div = document.getElementById('contents_profil');
 
if(window.XMLHttpRequest) // Firefox
   xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
   xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else { // XMLHttpRequest non supporté par le navigateur
   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
   return;
}
 
var method   = "GET";
var filename = "profil.xml";
var data     = "";
 
xhr_object.open(method, filename, true);
 
xhr_object.onreadystatechange = function() {
	if(xhr_object.readyState == 4) {
		var xmlDoc = xhr_object.responseXML.documentElement;
		var couple = xmlDoc.getElementsByTagName('couple');
 
		for (var iC=0 ; iC < couple.length ; iC++){
			var champs = couple[iC].getElementsByTagName('champs')[0].firstChild.nodeValue;
			var value = couple[iC].getElementsByTagName('value')[0].firstChild.nodeValue;
			addnode(div,champs,value);
			document.getElementById(champs).indice = value; 
			document.getElementById(champs).onclick = function() {modifnodeinput(this.id)};
		}
	}
}
xhr_object.send(data);
 
}
function addnode(el,champs,value){
	var childEl_c=document.createElement("div");
	el.appendChild(childEl_c);
	childEl_c.className='item';
	var childEl_ch=document.createElement("span");
	childEl_c.appendChild(childEl_ch);
	childEl_ch.className='champs';
	var childEl_v=document.createElement("span");
	childEl_c.appendChild(childEl_v);
	childEl_v.className='value';
	childEl_v.id = champs;
	var txtNode=document.createTextNode(champs + " : ");
	childEl_ch.appendChild(txtNode);
	var txtNode=document.createTextNode(value);
	childEl_v.appendChild(txtNode);
}
 
function modifnodeinput(champs)
{
var childEl_old = document.getElementById(champs);
var childEl_new = document.createElement("input");
var parent = childEl_old.parentNode;
 
parent.replaceChild(childEl_new,childEl_old);
 
childEl_new.id = champs;
childEl_new.value = childEl_old.indice;
childEl_new.focus()
childEl_new.onblur = function() {modifnodespan(this.id)};
 
}
 
function modifnodespan(champs)
{
var childEl_old = document.getElementById(champs);
var childEl_new = document.createElement("span");
var parent = childEl_old.parentNode;
 
var value = childEl_old.value
var txtNode = document.createTextNode(value);
 
parent.replaceChild(childEl_new,childEl_old);
 
childEl_new.appendChild(txtNode);
childEl_new.id = champs;
childEl_new.indice = value;
childEl_new.className='value';
 
childEl_new.onclick = function() {modifnodeinput(this.id)};
}
 
function AfficheTouche(e) {
	if (e.keyCode) codeTouche=e.keyCode;
	else codeTouche=e.which;
	if (codeTouche == "13"){
	actif = document.activeElement.id;
	modifnodespan(actif)}
}