日期:2014-05-16 浏览次数:20485 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<input type="text" id="i" value="2.3" onfocus="this.value='';" />
<button onclick="fun();">计算</button>
结果:<input type="text" id="result" />
<script language="javascript">
function $(Id){return document.getElementById(Id);}
function fun()
{
var j = 33;
var i = $('i');
$('result').value = accMul(j,i.value);
}
function accMul(arg1,arg2)
{
var m=0,s1=arg1.toString(),s2=arg2.toString();
try{m+=s1.split(".")[1].length}catch(e){}
try{m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
</script>
</body>
</html>