<style type="text/css">
#gezi{
width:460px;
height:400px;
margin-left:auto;
margin-right:auto;
margin-top:50px;
overflow:hidden;
text-align:center;
background: #666;
border:5px solid #000;}
</style>
<script>
function compute(){
str1=Number(document.getElementById("txt1").value);
str2=Number(document.getElementById("txt2").value);
cc=document.getElementById("form").value;
var result;
switch(cc) {
case "+":
cc=str1+str2;
break;
case "-":
cc=str1-str2;
break;
case "*":
cc=str1*str2;
break;
case "%":
cc=str1%str2;
case "/":
if(str2==0){
alert("除數不能為0!");
cc='';
}else{
cc=str1/str2;
}
break;
}
document.getElementById("result").value=https://bbs.csdn.net/topics/cc;
}
</script>
</head>
<body>
<div id="gezi">
<h1>四則運算</h1>
第一個數:<input type="text" id="txt1"/><br />
第二個數:<input type="text" id="txt2"/><br />
<input type="submit" value="https://bbs.csdn.net/topics/+" id="form"/>
<input type="submit" value="https://bbs.csdn.net/topics/-" id="form"/>
<input type="submit" value="https://bbs.csdn.net/topics/*" id="form" />
<input type="submit" value="https://bbs.csdn.net/" id="form"/>
<input type="submit" value="https://bbs.csdn.net/topics/%" id="form"/>
<br />
<input type="button" id="b1" value="https://bbs.csdn.net/topics/等于" onclick="compute()" />
<input type="text" id="result"/>
</div>
</body>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/269315.html
標籤:基礎類
上一篇:自學SQL server,求教:為什么update陳述句報錯?
下一篇:求大神幫我看看哪里出了錯
