Shadow Wizard帮我向我展示这段代码:
<%
Set oRS= TarefasConexaoMSSQL.Execute("SELECT * FROM apptabela ORDER BY oito ASC")
Dim currentGroupName, previousGroupName
currentGroupName = ""
previousGroupName = ""
Do Until oRS.EOF
currentGroupName = oRS("oito")
One = oRS("um")
Two = oRS("dois")
If currentGroupName<>previousGroupName Then
Response.Write("<p>")
Response.Write("<a href='#'>" & currentGroupName & "</a>")
Response.Write("</p>")
End If
Response.Write("- One: " & One & ", Two: " & Two & "<br />")
previousGroupName = currentGroupName
oRS.MoveNext
Loop
oRS.Close
%>
它产生了类似的东西:
1000
- 一个:苹果,两个:梨
- One:Volks,Two:Lexus
1001
- One:Car,Two:Boat
1002
- 一:鸡,两只:奶牛
- 一个:笔,两个:铅笔
- 一:C#,二:C ++
我想要的是在每个组的底部添加一行,如Sum,所以稍后我可以做一些计算:
1000
- 一个:苹果,两个:梨
- One:Volks,Two:Lexus
- SUM:X,Y
1001
- One:Car,Two:Boat
- SUM:X,Y
1002
- 一:鸡,两只:奶牛
- 一个:笔,两个:铅笔
- 一:C#,二:C ++
- SUM:X,Y
由于
答案 0 :(得分:0)
http://www.pengoworks.com/workshop/jquery/calculation/calculation.plugin.htm
您可以根据您的要求使用此jquery插件。如果您无法理解如何实施,请告诉我。我最近用过这个。
答案 1 :(得分:0)
<%
Set oRS= TarefasConexaoMSSQL.Execute("SELECT * FROM apptabela ORDER BY oito ASC")
Dim currentGroupName, previousGroupName, sumone, sumtwo
currentGroupName = ""
previousGroupName = ""
Do Until oRS.EOF
currentGroupName = oRS("oito")
One = oRS("um")
Two = oRS("dois")
If currentGroupName<>previousGroupName Then
(!)Response.write("- Sum: " & sumone & ", " & sumtwo)
(!)sumone = 0 / ""
(!)sumtwo = sumone
Response.Write("<p>")
Response.Write("<a href='#'>" & currentGroupName & "</a>")
Response.Write("</p>")
End If
Response.Write("- One: " & One & ", Two: " & Two & "<br />")
(!)sumone = sumone + one
(!)sumtwo = sumtwo + two
previousGroupName = currentGroupName
oRS.MoveNext
Loop
oRS.Close
%>
这个应该解决它。因为你按groupname排序并想要每个组的总和,你必须在打印组元素时总结一下并在goint进入新组时打印总和+在再次总结之前清除总和。如果你正在使用字符串,这也应该有用,但也许你想在总结时添加空格