function myCon() { var FromVal, ToVal, FromName, ToName, v1; v1 = document.MainForm.what.value; v1 = stripBad(v1); v1 = parseFloat(v1); if (isNaN(v1)) v1 = 1; document.MainForm.what.value = v1; FromVal = document.MainForm.from[document.MainForm.from.selectedIndex].value; ToVal = document.MainForm.to[document.MainForm.to.selectedIndex].value; FromName = document.MainForm.from.options[document.MainForm.from.selectedIndex].text; ToName = document.MainForm.to.options[document.MainForm.to.selectedIndex].text; document.MainForm.answer.value = v1 + " " + FromName + " = " + get_fact(v1, FromVal, ToVal) + " " + ToName; } function resetanswer() { document.MainForm.answer.value = ""; } function get_fact(ff,from_val,to_val){ var temp = a[from_val] / a[to_val]; //var temp = a[from_val] * (1/a[to_val]); ff *= temp; ff = Math.round(ff *1000000)/1000000; return comma(ff); } function stripBad(string) { for (var i=0, output='', valid="eE-0123456789."; i -1){ myDec = myNum.substring(myNum.indexOf('.',0),myNum.length); } var arr=new Array('0'), i=0; while (n>0) {arr[i]=''+n%1000; n=Math.floor(n/1000); i++;} arr=arr.reverse(); for (var i in arr) if (i>0) //padding zeros while (arr[i].length<3) arr[i]='0'+arr[i]; return arr.join() + myDec; }