bonjour,
je suis une quiche en javascript et j'ai besoin de faire une ptite fonction qui additionne des valeurs r�cup�r�es dans un fichier txt...
mon soucis c'est qu'il r�cup�re les donn�es du fichier txt sous forme de chaine de caract�re donc si j'ai comme valeurs, 18, 12, 5 j'ai comme r�sultat 18125 or il faut que je me retrouve avec 35 !!
voil� ma fonction
sachant que le fichier HOUAT_tmp_imput.txt contient par exemple : app/18:mat/12:res/5:
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 function check_cal(){ var xhr_object = null; 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; } xhr_object.open("GET", "tmp/HOUAT_tmp_create.txt", false); xhr_object.send(null); if(xhr_object.readyState == 4) var crecre = xhr_object.responseText.split(":"); var creval = crecre[0].split("/"); xhr_object.open("GET", "tmp/HOUAT_tmp_imput.txt", false); xhr_object.send(null); if(xhr_object.readyState == 4) var impimp = xhr_object.responseText.split(":"); var implen = impimp.length - 2; var imptot = 0; for (i = 0; i <= implen; i++){ var impval = impimp[i].split("/"); imptot = imptot + impval[1]; } alert(imptot) }
il faut donc que imptot soit �gal � 35 et non 018125 !!
comment faire ??
merci de votre aide
Partager