The method in this article is super simple and the ideas are highly recommended. Friends, please refer to it
javascript simple calculator
<script> <br>
//Define global variables var one="1"; <br>
var two="2"; <br>
var three="3"; <br>
var four="4"; <br>
var five="5"; <br>
var six="6"; <br>
var seven="7"; <br>
var eight="8"; <br>
var nine="9"; <br>
var zero="0"; <br>
var plus=" ",minus="-",multiply="*",divide="/",decimal="."; <br>
function enter(obj,string){ <br>
to
} <br>
function compute(obj){//The function called by clicking the equals "=" button; obj.expr.value=eval(obj.expr.value);//Use JS to get the eval() method to calculate name as the formula in expr } <br>
</script>
是不是超级NB的代码,大神级的!