function calculate() { var select1 = document.currcalc.from_tkc; var select2 = document.currcalc.to_tkc; var select1_text = select1[select1.selectedIndex].text; var select2_text = select2[select2.selectedIndex].text; var fromval; //Value of the currency to be converted var toval; //Value of the currency to convert into //These error messages are hidden values in the HTML page //They get translated into foreign languages var errmsg1 = document.currcalc.translation1.value; var errmsg2 = document.currcalc.translation2.value; var errmsg3 = document.currcalc.translation3.value; //calculate the fixed Euro value if (select1_text.match(/\(EUR\)/) != null) { var temp = select2_text.split("("); var lastsplit = temp.length - 1; var result = temp[lastsplit].match(/(FRF|ATS|PTE|ESP|BEF|NLG|FIM|DEM|IEP|ITL|LUF|GRD)/); if (result != null) { fromval = 1; toval = eurovals[result[0]]; } } //calculate the fixed Euro value if (select2_text.match(/\(EUR\)/) != null) { var tmp = select1_text.split("("); var lstsplit = tmp.length - 1; var result = tmp[lstsplit].match(/(FRF|ATS|PTE|ESP|BEF|NLG|FIM|DEM|IEP|ITL|LUF|GRD)/); if (result != null) { toval = 1; fromval = eurovals[result[0]]; } } //set the prices if (fromval == null && toval == null) { fromval = price[select1[select1.selectedIndex].value]; toval = price[select2[select2.selectedIndex].value]; } //check to make sure that there is a valid price/ valid currency for each if ((fromval < 0) || (fromval == "") || isNaN(fromval) || (toval < 0) || (toval == "") || isNaN(toval)){ alert(errmsg1); return false; } //assign the amount and check that it is valid, remove any punctuation //amount is the number of the base currency units specified by the user var amount = document.currcalc.amount.value; if ((amount == "") || isNaN(amount) || (amount == 0) || (amount < 1)){ alert(errmsg2); document.currcalc.amount.focus(); return false; } var pattern = /,/g; amount = amount.replace(pattern, ""); //show all results ShowResult(fromval, toval, amount); } //window.onload = calculate;
英国学子教育SUUK旗下社区网站
客服电话:英国 08444930990   中国 4006806030
[切换社区]
 
兑换数量:
loadResults(); calculate();