现一页面的数据计算问题

ypw008 2010-07-29 10:26:58
请问一下,如何实现如下 的功能

就是在上面的输入框里输入 分数后,下面的总分框自动计算上面的分数之和,而不要点确定。
...全文
49 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ypw008 2010-08-02
已搞定了,谢谢名位的帮助。
回复
ypw008 2010-08-01
请高手们指点一下啊!!
回复
lbcleo 2010-07-30
js也可以,表格都固定了,只要取出每个表格内容,最后下面那个输出就可以了
回复
yangtututu 2010-07-30
楼上正解, 混分
回复
ypw008 2010-07-30
谢谢各位的解答 。我想要的是不用点击总分这栏,总分就自动计算出来,并且科目和调查项目是从数据库里动态读取的。不同的年级调查科目是不同的。下面是这一页的源代码。请各们帮忙看一下。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<%
'判断班级名是否为空
if (Session("MM_username") = "") Then
Response.Redirect("index.asp")
end if
%>
<%
'获取班级编号并把傎赋给变量bjon
Dim bjon
If (Session("MM_username") <> "") Then
bjon = Session("MM_username")
End If
%>
<%
'获取班级名称
dim bjname,Rsbjname,sqlbjname
Set Rsbjname = Server.CreateObject("ADODB.Recordset")
sqlbjname="select bjname from bjlb where bjon='"&bjon&"'"
Rsbjname.open sqlbjname,dbconnection,adOpenDynamic,3
bjname=(Rsbjname("bjname"))

%>
<%
'获取年级编号
dim njon,Rsbjon,sqlstr
Set Rsbjon = Server.CreateObject("ADODB.Recordset")
sqlstr="select njon from bjlb where bjon='"&bjon&"'"
Rsbjon.open sqlstr,dbconnection,adOpenDynamic,3
njon=(Rsbjon("njon"))

%>

<%
'获取年级科目
dim Rskm,sqlkm,kmname,kmid
Set Rskm = Server.CreateObject("ADODB.Recordset")
sqlkm="select * from kmlb where njon="&njon&" order by kmon"
Rskm.open sqlkm,dbconnection,adOpenDynamic,3
kmname=(Rskm("kmname"))
kmid=(Rskm("kmid"))

%>
<%
'获取调查项目
dim Rsdcxm,sqldcxm,dcxmnr
Set Rsdcxm = Server.CreateObject("ADODB.Recordset")
sqldcxm="select dcxmnr from dcxm order by dcxmid"
Rsdcxm.open sqldcxm,dbconnection,adOpenDynamic,3
dcxmnr=(Rsdcxm("dcxmnr"))

%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>遵义市汇川区高坪中学教师期末教学调查系统</title>
<style type="text/css">
<!--
.STYLE2 {
font-size: 16px;
font-weight: bold;
color: #FF0066;
}
body {
background-color: #9999FF;
}
.STYLE4 {font-size: 20px}
.STYLE5 {color: #990066; font-weight: bold;}
.STYLE7 {font-size: 18px}
-->


</style>
</head>

<body>
<div align="center"><img src="images/gpzhxdcxmlog.png" width="776" border="2" /></div>
<div align="center" class="STYLE4"><span class="STYLE5">你进入的是:
<%Response.Write(bjname)%>
,请你认真核对选择是否正确!!</span> <a href="index.asp">返回重新选择班级</a></div>
<form action="" method="post" name="form1" id="form1">
<table width="780" border="1" align="center" bordercolor="#CC0000" bgcolor="#CCCCCC">


<tr>
<td><p>              科目</p>
<p>调查项目</p></td>

<%
'科目循环
While NOT Rskm.EOF
%>

<td><%=(Rskm.Fields.Item("kmname").Value)%></td>
<%
Rskm.MoveNext()
Wend
%>
</tr>
<%
dim i
i=1
%>
<%
'调查项目循环
Rsdcxm.Movefirst()
While NOT Rsdcxm.EOF
%>

<tr>
<td width="200"><%=(Rsdcxm.Fields.Item("dcxmnr").Value)%></td>
<%
Rskm.Movefirst()
While NOT Rskm.EOF
%>

<td><input name="<%=(Rskm.Fields.Item("kmon").Value)%><% Response.Write(i)%>" type="text" size="3" maxlength="2"

/></td>

<%
Rskm.MoveNext()
wend
%>
</tr>
<%
i=i+1
%>
<%
Rsdcxm.MoveNext()
Wend
%>
<tr>
<td align="center"><span class="STYLE2">总分</span></td>
<%
Rskm.Movefirst()
While NOT Rskm.EOF
%>
<td><input name= "zf<%=(Rskm.Fields.Item("kmon").Value)%>" type="text" value="" size="3" maxlength="3" /></td>
<%
Rskm.MoveNext()
wend
%>
</tr>
</table>

<div align="center">
<span class="STYLE7">
<input name="yes" type="submit" class="STYLE4" value="提 交" />
   
<input name="no" type="reset" class="STYLE4" value="重 填" />
</span>

</div>
</form>


</body>
</html>
<%
Rsbjon.close
set Rsbjon=nothing
%>
<%
Rsdcxm.close
set Rsdcxm=nothing
%>
<%
Rskm.close
set Rskm=nothing
%>
回复
lzp4881 2010-07-30
<html>
<body>
<script>
function sum(){
var obj = document.getElementsByName("aa");
var sum = 0;
for (j=0;j<obj.length;j++){
if(obj.item(j).value!=""){
sum += obj.item(j).value*1;
};
}
return sum;
}
</script>
<%
for i=1 to 5
%>
A<%=i%>:<input type="text" name="aa" onblur="hj.value=sum()"/><br>
<%
next
%>
合计:<input type="text" name="hj"/><br>
</body>
</html>
回复
qiangdeng 2010-07-30
<html>
<body>
<script>
function sum(ttt){
var obj = document.getElementsByName("aa"+ttt);
var sum = 0;
for (j=0;j<obj.length;j++){
if(obj.item(j).value!=""){
sum += obj.item(j).value*1;
};
}
return sum;
}
</script><%
for j=1 to 5
%>
<%
for i=1 to 5
%>
A<%=i%>:<input type="text" name="aa" onblur="hj<%=j%>.value=sum(<%=j%>)"/><br>
<%
next
%>
合计:<input type="text" name="hj<%=j%>"/><br><%
next
%>

</body>
</html>
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告