<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题文档</title>
<script type="text/javascript">
function count()
{
var d1=document.getElementById("id1").value;
var d2=document.getElementById("id2").value;
var d3=document.getElementById("id3").value;
var d="";
switch(d3){
case "+":
d = parseFloat(d1) + parseFloat(d2);
break;
case "-":
d = parseFloat(d1) - parseFloat(d2);
break;
case "*":
d = parseFloat(d1) * parseFloat(d2);
break;
default:
d = parseFloat(d1) / parseFloat(d2);
}
document.getElementById("id4").value=d;
}
</script>
</head>
<body>
<input type="text" id="id1" />
<select id="id2">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" id="id3" />
<input type="button" id="id3" value="=" onclick="count()"/>
<input type="text" id="id4" />
</body>
</html>
跑起来点击等于的时候显示那N
我們
相关分类