关于ASP动态网页设计的编程
3个回答
展开全部
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div id = "test">
<label>请输入数字:</label>
<input id="inputNum" type="text" />
<br/>
<input type="button" value="计算" onclick="javascript:sum();" />
</div>
<script type="text/javascript">
sum = function()
{
var endNum = document.getElementById("inputNum").value;
if(!endNum)
{
alert("数字不能为空");
return;
}
if(isNaN(endNum))
{
alert("请输入数字");
return;
}
var sum = 0;
for(var index = 1; index <= endNum; index++)
{
sum += index;
}
alert("和为:"+ sum);
}
</script>
</body>
</html>
<head runat="server">
<title></title>
</head>
<body>
<div id = "test">
<label>请输入数字:</label>
<input id="inputNum" type="text" />
<br/>
<input type="button" value="计算" onclick="javascript:sum();" />
</div>
<script type="text/javascript">
sum = function()
{
var endNum = document.getElementById("inputNum").value;
if(!endNum)
{
alert("数字不能为空");
return;
}
if(isNaN(endNum))
{
alert("请输入数字");
return;
}
var sum = 0;
for(var index = 1; index <= endNum; index++)
{
sum += index;
}
alert("和为:"+ sum);
}
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询