Home > database >  Sign of operation how to perform, which is wrong
Sign of operation how to perform, which is wrong

Time:03-23

<style type="text/CSS" & gt;
# gezi {
Width: 460 px;
Height: 400 px;
margin-left:auto;
Margin - right: auto;
Margin - top: 50 px;
overflow:hidden;
text-align:center;
Background: # 666;
Border: 5 px solid # 000; }

</style>
<script>
The function compute () {
Str1=Number (document. GetElementById (" txt1 "). The value).
Str2=Number (document. GetElementById (" txt2 "). The value).
Cc=document. GetElementById (" form "). The value;
Var result;
The switch (cc) {
The case "+" :
Cc=str1 + str2;
break;
Case "-" :
Cc=str1 - str2;
break;
A case of "*" :
Cc=str1 * str2;
break;
Case "%" :
Cc=str1 % str2;
Case "/" :
If (str2==0) {
Alert (" divisor cannot be zero!" );
Cc=' ';
} else {
Cc=str1/str2;
}
break;
}
Document. The getElementById (" result "). value=https://bbs.csdn.net/topics/cc;
}
</script>


<body>

The first number: & lt; Input type="text" id="txt1"/& gt;
Number 2: & lt; Input type="text" id="txt2"/& gt;


  • Related