<html>
<body>
<body>
<div id="monitor" > </div>
<br>
<input type="button" onclick="putToMonitor(this)" value="1">
<input type="button" onclick="putToMonitor(this)" value="2">
<input type="button" onclick="putToMonitor(this)" value="3"><br>
<input type="button" onclick="putToMonitor(this)" value="4">
<input type="button" onclick="putToMonitor(this)" value="5">
<input type="button" onclick="putToMonitor(this)" value="6"><br>
<input type="button" onclick="putToMonitor(this)" value="7">
<input type="button" onclick="getOperator(this)" value="+">
<input type="button" onclick="getOperator(this)" value="*">
<input type="button" onclick="cal()" value="=">
<br>
<input type="button" onclick="putToMonitor(this)" value="1">
<input type="button" onclick="putToMonitor(this)" value="2">
<input type="button" onclick="putToMonitor(this)" value="3"><br>
<input type="button" onclick="putToMonitor(this)" value="4">
<input type="button" onclick="putToMonitor(this)" value="5">
<input type="button" onclick="putToMonitor(this)" value="6"><br>
<input type="button" onclick="putToMonitor(this)" value="7">
<input type="button" onclick="getOperator(this)" value="+">
<input type="button" onclick="getOperator(this)" value="*">
<input type="button" onclick="cal()" value="=">
<script>
var num1=0;
var num2=0;
var op;
var first=true;
function putToMonitor(a){
document.getElementById("monitor").innerHTML=
var num1=0;
var num2=0;
var op;
var first=true;
function putToMonitor(a){
document.getElementById("monitor").innerHTML=
document.getElementById("monitor").innerHTML+a.value;
if(first){
num1=num1*10;
num1=parseInt(num1)+parseInt(a.value);
}
else{
num2=num2*10;
num2=parseInt(num2)+parseInt(a.value);
}
}
function getOperator(a){
document.getElementById("monitor").innerHTML=
if(first){
num1=num1*10;
num1=parseInt(num1)+parseInt(a.value);
}
else{
num2=num2*10;
num2=parseInt(num2)+parseInt(a.value);
}
}
function getOperator(a){
document.getElementById("monitor").innerHTML=
document.getElementById("monitor").innerHTML+a.value;
op=a.value;
first=false;
op=a.value;
first=false;
}
function cal( ){
first=true;
if(op=="+")
document.getElementById("monitor").innerHTML=parseInt(num1)+parseInt(num2);
else if (op=="*")
document.getElementById("monitor").innerHTML=num1*num2;
}
</script>
function cal( ){
first=true;
if(op=="+")
document.getElementById("monitor").innerHTML=parseInt(num1)+parseInt(num2);
else if (op=="*")
document.getElementById("monitor").innerHTML=num1*num2;
}
</script>
</body>
</html>
</html>
- ۹۳/۰۹/۲۶