1个回答
展开全部
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>小小asp计算器</title>
</head>
<body>
<%
'-------------------------------
'janchie 原创 2007.3.15
dim str,num1,numtag,num2,action
num1=request.form("num1")
numtag=request.form("numtag")
num2=request.form("num2")
action=request.querystring ("action")
if action="count" then
if not isnumeric(num1) or trim(num1)="" then
response.write "第一项不能为空,且只能填入数字!"
elseif numtag="" then
response.write "运算方式没有选择!"
elseif not isnumeric(num2) or trim(num2)="" then
response.write "第三项不能为空,且只能填入数字!"
else
str=counts(cdbl(num1),numtag,cdbl(num2))
if numtag<>"%" then
if str<1 and str>0 then
str="0"&str
end if
end if
end if
end if
function counts(n1,s,n2)
dim countstr
if s="/" and n2=0 then
exit function
end if
if s="%" and n2=0 then
exit function
end if
select case s
case "+"
countstr=n1+n2
case "-"
countstr=n1-n2
case "*"
countstr=n1*n2
case "/"
countstr=n1/n2
case "%"
countstr=formatpercent(n1/n2)
case else
countstr=0
end select
counts=countstr
end function
function checked(s1,s2)
if s1=s2 then
checked=" selected"
end if
end function
%>
<form name="form1" method="post" action="index.asp?action=count">
<p>
<input name="num1" type="text" id="num1" <%if action="count" then response.write "value="""&num1&"""" %>/>
<select name="numtag">
<option value="+" <%=checked("+",numtag)%>>+</option>
<option value="-" <%=checked("-",numtag)%>>-</option>
<option value="*" <%=checked("*",numtag)%>>×</option>
<option value="/" <%=checked("/",numtag)%>>÷</option>
<option value="%" <%=checked("%",numtag)%>>%</option>
</select>
<input name="num2" type="text" id="num2" <%if action="count" then response.write "value="""&num2&"""" %>/>
=
<input name="num3" type="text" id="num3" <%if action="count" then response.write "value="""&str&"""" %> style="color:red" />
</p>
<input type="submit" name="submit" value="马上计算" />
<input type="reset" name="reset" value="重新来过" onclick="location.href='index.asp';"/>
</form>
</body>
</html>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>小小asp计算器</title>
</head>
<body>
<%
'-------------------------------
'janchie 原创 2007.3.15
dim str,num1,numtag,num2,action
num1=request.form("num1")
numtag=request.form("numtag")
num2=request.form("num2")
action=request.querystring ("action")
if action="count" then
if not isnumeric(num1) or trim(num1)="" then
response.write "第一项不能为空,且只能填入数字!"
elseif numtag="" then
response.write "运算方式没有选择!"
elseif not isnumeric(num2) or trim(num2)="" then
response.write "第三项不能为空,且只能填入数字!"
else
str=counts(cdbl(num1),numtag,cdbl(num2))
if numtag<>"%" then
if str<1 and str>0 then
str="0"&str
end if
end if
end if
end if
function counts(n1,s,n2)
dim countstr
if s="/" and n2=0 then
exit function
end if
if s="%" and n2=0 then
exit function
end if
select case s
case "+"
countstr=n1+n2
case "-"
countstr=n1-n2
case "*"
countstr=n1*n2
case "/"
countstr=n1/n2
case "%"
countstr=formatpercent(n1/n2)
case else
countstr=0
end select
counts=countstr
end function
function checked(s1,s2)
if s1=s2 then
checked=" selected"
end if
end function
%>
<form name="form1" method="post" action="index.asp?action=count">
<p>
<input name="num1" type="text" id="num1" <%if action="count" then response.write "value="""&num1&"""" %>/>
<select name="numtag">
<option value="+" <%=checked("+",numtag)%>>+</option>
<option value="-" <%=checked("-",numtag)%>>-</option>
<option value="*" <%=checked("*",numtag)%>>×</option>
<option value="/" <%=checked("/",numtag)%>>÷</option>
<option value="%" <%=checked("%",numtag)%>>%</option>
</select>
<input name="num2" type="text" id="num2" <%if action="count" then response.write "value="""&num2&"""" %>/>
=
<input name="num3" type="text" id="num3" <%if action="count" then response.write "value="""&str&"""" %> style="color:red" />
</p>
<input type="submit" name="submit" value="马上计算" />
<input type="reset" name="reset" value="重新来过" onclick="location.href='index.asp';"/>
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询