<!-- 杩欐槸涓€涓绠楀櫒 -->
<%@ page contentType="text/html; charset=gb2312" %>
<html>
<h1>璁$畻鍣?lt;/h1>
<hr>
<script language = "javascript">
function checkNum(){
// alert("1");alert("0");
if(document.form1.num1.value == ""){ //娉ㄦ剰杩欓噷鍙兘浣跨敤 == 涓嶈兘浣跨敤equals("")浠ヤ负js涓病鏈塭quals鍑芥暟 alert("num涓虹┖");
return false;
}
//鍒ゆ柇杈撳叆鐨勭殑鏄笉鏄暟瀛?br> if(Math.round(document.form1.num1.value) != document.form1.num1.value){
alert("杈撳叆鐨勪笉鏄痭um1鏁板瓧绫诲瀷銆傝鏍稿疄");
return false;
}
if(Math.round(document.form1.num2.value) != document.form1.num2.value){
alert("杈撳叆鐨勪笉鏄痭um2鏁板瓧绫诲瀷銆傝鏍稿疄");
return false;
}
if(document.form1.operator.value == "/" && document.form1.num2.value == 0){
alert("闄ゆ暟涓嶈兘涓?");
return false;
}
}
</script>
<body>
<!-- 鏄剧ず缁撴灉 -->
<!--
<%
//鎺ュ彈绗竴涓繍绠楁暟
String strNum1 = request.getParameter("num1");
//鎺ュ彈绗簩涓簯绠楁暟
String strNum2 = request.getParameter("num2");
//System.out.println("strNum2="+ strNum2);
//鎺ュ彈杩愮畻绗?br> String operator = request.getParameter("operator");
//璁$畻缁撴灉
int num11=0, num22=0,result=0;
out.println("12345");
if(strNum1 != null && strNum2 != null && operator != null){
out.println("涓嶇瓑浜庣┖=============");
// return false;
try{
num11 = Integer.parseInt(strNum1);
num22 = Integer.parseInt(strNum2);
if(operator.equals("+")){
result = num11 + num22;
}else if(operator.equals("-")){
result = num11 - num22;
}else if(operator.equals("*")){
result = num11 * num22;
}else if(operator.equals("/")){
result = num11/num22;
}
}catch(Exception e){
e.printStackTrace();
out.println("12345678");
}
// out.println(strNum1+operator+strNum2+"="+ result);
}
%>
-->
<form name = "form1" action="myCal.jsp">
璇疯緭鍏ョ涓€涓暟锛?lt;input type="text" name="num1" value="<%=strNum1 %>"><br>
<select name = "operator">
<option value=+>+</option>
<option value=->-</option>
<option value=*>*</option>
<option value=/>/</option>
</select><br>
璇疯緭鍏ョ浜屼釜鏁帮細<input type="text" name="num2" value="<%=strNum2 %>"><br>
<input type=submit onclick="return checkNum()" value="绛変簬">
</form>
缁撴灉锛?lt;%= strNum1%><%=operator %><%= strNum2%>=<%= result %>
</body>
</html>