-1

这是我基于我的代码的链接....但是如果有意义的话,我希望有两个以上的区域可以输入数字...所以数字 1,数字 2,然后数字 3... ETC

关联

我试图将所有内容复制下来,然后添加

c=Number(document.calculator.number3.value); 
d=Number(document.calculator.number4.value);

<!-- Here user will enter 3rd number. -->   
Number 3: <input type="text" name="number3">  
<!-- Here user will enter 4th number. -->   
Number 4: <input type="text" name="number4">  

并将结果更改为 e=a+b+c+d 但随后计算器停止运行

任何帮助,将不胜感激

4

1 回答 1

3

试试 - http://jsfiddle.net/GmDuE/

HTML

Number 1: <input type="text" name="number1">
Number 2: <input type="text" name="number2">
Number 3: <input type="text" name="number3">
Number 4: <input type="text" name="number4">

JS

<script language="javascript" type="text/javascript">
function multiply(){
a=Number(document.calculator.number1.value);
b=Number(document.calculator.number2.value);
c=Number(document.calculator.number3.value);
d=Number(document.calculator.number4.value);
m=a*b*c*d;
document.calculator.total.value=m;
}

function addition(){
a=Number(document.calculator.number1.value);
b=Number(document.calculator.number2.value);
c=Number(document.calculator.number3.value);
d=Number(document.calculator.number4.value);
m=a+b+c+d;
document.calculator.total.value=m;
}
</script>

etc.
于 2012-06-20T23:16:52.817 回答