<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>******计算机******</title>
<script type="text/javascript">
window.onload = function(){
var oInput01=document.getElementById('input01')
var oInput02=document.getElementById('input02')
var oFuHao=document.getElementById('fuhao')
var oBtn=document.getElementById('btn')
oBtn.onclick=function(){
var num01=oInput02.value;
var num02=oInput02.value;
var fuhao=oFuHao.value;
if(num01==""||num01==""){
alert('数字不能为空!');
return;
}
if(isNaN(num01)||isNaN(num02)){
alert('请输入数字!');
return;
}
switch(fuhao){
case '0':
alert((parseFloat(num01)*100+parseFloat(num02)*100)/100);
break;
case '1':
alert((parseFloat(num01)*100-parseFloat(num02)*100)/100);
break;
case '2':
alert(((parseFloat(num01)*100)*(parseFloat(num02)*100))/10000);
break;
case '3':
alert((parseFloat(num01)*100)/(parseFloat(num02)*100));
break;
}
}
}
</script>
</head>
<body>
<h1>计算机</h1>
<input type="text" name="" id="input01" />
<select id="fuhao">
<option value="0">+</option>
<option value="1">-</option>
<option value="2">*</option>
<option value="3">/</option>
</select>
<input type="text" name="" id="input02" />
<input type="button" name="" value="计算" id="btn" />
</body>
</html>