javascript 实现简单计算器功能 急!!

来源:百度知道 编辑:UC知道 时间:2024/06/17 06:07:36
<HTML>
<script>
function cas(){
var a=document.getElementById("first").value;
var b=document.getElementById("sercond").value;
if(document.kfc.getElementByld("sign").value=="a"){
document.kfc.result.value=parseInt(a)+parseInt(b);
}
if(document.getElementByld("sign").value=="b"){
document.kfc.result.value=parseInt(a)-parseInt(b);
}
if(document.getElementByld("sign").value=="c"){
document.kfc.result.value=parseInt(a)*parseInt(b);
}
if(document.getElementByld("sign").value=="d"){
document.kfc.result.value=parseInt(a)/parseInt(b);
}
}
</script>

<BODY>
<form name="kfc">
输入第一个数<input type="text" id="first" >
<select id="sign">
<option value="a">+</o

<HTML>
<script>
function cas(){
var a=document.getElementById("first").value;
var b=document.getElementById("sercond").value;
if(document.kfc.sign.value=="a"){
document.kfc.result.value=parseInt(a)+parseInt(b);
}
if(document.kfc.sign.value=="b"){
document.kfc.result.value=parseInt(a)-parseInt(b);
}
if(document.kfc.sign.value=="c"){
document.kfc.result.value=parseInt(a)*parseInt(b);
}
if(document.kfc.sign.value=="d"){
document.kfc.result.value=parseInt(a)/parseInt(b);
}
}
</script>

<BODY>
<form name="kfc">
输入第一个数<input type="text" id="first" >
<select id="sign" name="sign">
<option value="a">+</option>
<option value="b">-</option>
<opt