< form id = "form1" name = "form1" method = "post" action = "" >

 < label >

 < input type = "text" name = "t1" /><input type="text" name="t2" />

< input type = "text" name = "t3" /> <input type="button" name="Submit" value="计算" onclick="js();" />

 </label>

 </form >

< script >

 function js() {  

   form1.t2.value = formatFloat(form1.t1.value / 100 * 90, 4);  

   form1.t3.value = formatFloat(form1.t1.value / 100 * 10, 4);

}

 function formatFloat(src, pos) {  

   return Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos);

}

 </script>

posted on 2012-03-20 13:08  Asa.Zhu  阅读(152)  评论(0编辑  收藏  举报