- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
function convert(val){
var TablePrice = document.getElementById("main_price");
var trList = TablePrice.getElementsByTagName("tr");
var IdVal = document.getElementById("IndocatorCurHide");
var IdCur = document.getElementById("IndocatorCur");
var CurUSD = parseFloat(document.getElementById("CurUSD").innerHTML);
var CurRUR = parseFloat(document.getElementById("CurRUR").innerHTML);
var CurEUR = parseFloat(document.getElementById("CurEUR").innerHTML);
var Kurce = 1;
var KurceUAH = 1;
switch (val) {
case "RUR":
IdCur.style.backgroundImage = "url('flags/FlagsRussia.jpg')";
break;
case "EUR":
IdCur.style.backgroundImage = "url('flags/FlagsEU.jpg')";
break;
case "USD":
IdCur.style.backgroundImage = "url('flags/FlagsUSA.jpg')";
break;
case "UAH":
IdCur.style.backgroundImage = "url('flags/FlagsUkraine.jpg')";
break;
}
for (var i = 0; i < trList.length; i++) {
var tdList = trList[i].getElementsByTagName('td');
for (j = 0; j < tdList.length; j++) {
if (tdList[j].id == "ToConvert") {
if ((tdList[j].innerHTML != "") && (tdList[j].innerHTML != "-")) {
var TmpPrice = parseFloat(tdList[j].innerHTML);
switch (IdVal.innerHTML) {
case "RUR":
switch (val) {
case "UAH":
TmpPrice *= CurRUR;
break;
case "EUR":
TmpPrice *= CurRUR;
TmpPrice /= CurEUR;
break;
case "USD":
TmpPrice *= CurRUR;
TmpPrice /= CurUSD;
break;
}
; break;
case "USD":
switch (val) {
case "UAH":
TmpPrice *= CurUSD;
break;
case "EUR":
TmpPrice *= CurUSD;
TmpPrice /= CurEUR;
break;
case "RUR":
TmpPrice *= CurUSD;
TmpPrice /= CurRUR;
break;
}
; break;
case "EUR":
switch (val) {
case "UAH":
TmpPrice *= CurEUR;
break;
case "RUR":
TmpPrice *= CurEUR;
TmpPrice /= CurRUR;
break;
case "USD":
TmpPrice *= CurEUR;
TmpPrice /= CurUSD;
break;
}
; break;
...
}
tdList[j].innerHTML = TmpPrice.toFixed(2);//Math.round(TmpPrice / 0.1) * 0.1;
Наткнулся на форуме JavaScript, функция для конвертирования валют =).
gegMOPO4 06.03.2011 19:31 # +4
Мистер Хэнки 12.03.2011 14:13 # +2