请问各位大侠,如何在用javascript实现例如:
有90条记录,共5页¦上一页 < <[1][2][3]...[4][5]> > 下一页¦到[ ]页 跳转(输入数字点跳转,到相应的页数) 这个功能的,我不需要从数据库读资料,只是通过发交易后读取响应的xml报文.
我可以得到总记录数(TotalNum),当前返回记录数(RecNum),并且每页固定显示20条数据,
希望各位能帮我写个算法,最好是用我给的变量帮我写个,谢谢了.....
有90条记录,共5页¦上一页 < <[1][2][3]...[4][5]> > 下一页¦到[ ]页 跳转(输入数字点跳转,到相应的页数) 这个功能的,我不需要从数据库读资料,只是通过发交易后读取响应的xml报文.
我可以得到总记录数(TotalNum),当前返回记录数(RecNum),并且每页固定显示20条数据,
希望各位能帮我写个算法,最好是用我给的变量帮我写个,谢谢了.....
ExpRecCount = 20 是我所需要的每页希望返回的记录条数,<%
Response.Expires=0
response.buffer=true
%><!--#include file="../Include/formatmoney.inc"-->
<!--#include file="ZSY_format.inc"-->
<!--#include file="ZSY_CurrCode.asp" -->
<% Title_s=request("Title_s")
TxCode_s=request("TxCode_s")
FuncId_s=request("FuncId_s")
SubFuncId_s=request("SubFuncId_s")
StartPos= request("StartPos") if StartPos="" then
StartPos=1
end if
ExpRecCount = cint(readIniFile("ExpRecCount"))
if ExpRecCount="" then
ExpRecCount=20
end if
UserId_s= Session("UserId")
AcctId_s=Request("AcctId")
DepId_s=Request("DepId")
UpAcctId_s=Request("UpAcctId")
StruSerial_s=Request("ChaXun")
SerialName_s=Request("SerialName") Outtxt = ""
Ostatu = 0
NameA =array("UserId","AcctId","DepId","UpAcctId","StruSerial","SerialName","StartPos","ExpRecCount")
ValueA =array(UserId_s,AcctId_s,DepId_s,UpAcctId_s,StruSerial_s,SerialName_s,StartPos,ExpRecCount)
StrXml =MakeXmlCms("4574","000",NameA,ValueA)
rel = tuxedo(StrXml, Outtxt, Ostatu)
Set xmlDoc = CreateObject("Msxml.DOMDocument")
xmlDoc.async = False
xmlDoc.loadxml (Outtxt)
Set UserId= xmlDoc.getElementsByTagName("UserId") Set AcctId= xmlDoc.getElementsByTagName("AcctId")
Set DepId= xmlDoc.getElementsByTagName("DepId")
Set CurCode= xmlDoc.getElementsByTagName("CurCode")
Set AcctName= xmlDoc.getElementsByTagName("AcctName")
Set AcctType= xmlDoc.getElementsByTagName("AcctType")
Set AcctLevel= xmlDoc.getElementsByTagName("AcctLevel")
Set UpAcctId= xmlDoc.getElementsByTagName("UpAcctId")
Set OpenBankName= xmlDoc.getElementsByTagName("OpenBankName")
Set StruSerial= xmlDoc.getElementsByTagName("StruSerial")
Set SerialName= xmlDoc.getElementsByTagName("SerialName")
Set RtnRecCount= xmlDoc.getElementsByTagName("RecCount")
Set TotalRec= xmlDoc.getElementsByTagName("TotalRec")
aspName = "ZSY4574000_00ok.asp"
EndCount = CDbl(StartPos) + CDbl(RtnRecCount.Item(0).Text) - 1
If TotalRec.Item(0).Text < EndCount Then
EndCount = TotalRec.Item(0).Text
End If
%>
<html>
<head>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<Script language="JavaScript" src="../Include/formatmoney.js"></Script>
<Script language="Vbscript" src="../Include/formatmoney.vs"></Script>
<link href="../include/css.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function firstpage(startpos,link){
//startpos-=20;
document.form1.StartPos.value=startpos;
document.form1.action=link;
document.form1.submit();
}
function lastpage(startpos,link){
startpos = startpos * <%=ExpRecCount%> + 1;
document.form1.StartPos.value=startpos;
document.form1.action=link;
document.form1.submit();
} function nextpage(startpos,link){
startpos+=<%=ExpRecCount%>;
document.form1.StartPos.value=startpos;
document.form1.action=link;
document.form1.submit();
}
function previouspage(startpos,link){
startpos-=<%=ExpRecCount%>;
document.form1.StartPos.value=startpos;
document.form1.action=link;
document.form1.submit();
}
</Script>
<title><%=Title_s%></title>
</head>
<body LANGUAGE="javascript" onafterprint="return window_onafterprint()" onbeforeprint="return window_onbeforeprint()" > <TABLE name=table1 id=table1 border=0 cellPadding=0 cellSpacing=0 width=530>
<TR>
<TD> </TD></TR>
<TR>
<TD height=20><%=ShowTitle(Title_s)%>
</TD></TR>
<TR>
<TD bgColor=#cccccc height=1><IMG height=1 src="/images/1x1.gif"
width=1></TD></TR>
<TR>
<TD height=1> </TD></TR></TABLE>
<FORM action=<%=aspName%> method=post name=form1 >
<input type="hidden" name="Title_s" value="<%=Title_s%>">
<input type="hidden" name="TxCode_s" value="<%=TxCode_s%>">
<input type="hidden" name="FuncId_s" value="<%=FuncId_s%>">
<input type="hidden" name="SubFuncId_s" value="<%=SubFuncId_s%>">
<input type="hidden" name="StartPos" value="<%=StartPos%>">
<input type="hidden" name="UserId" value="<%=Request("UserId")%>">
<input type="hidden" name="AcctId" value="<%=Request("AcctId")%>">
<input type="hidden" name="DepId" value="<%=Request("DepId")%>">
<input type="hidden" name="StruSerial" value="<%=Request("ChaXun")%>">
<input type="hidden" name="SerialName" value="<%=Request("SerialName")%>">
<input type="hidden" name="ChaXun" value="<%=Request("ChaXun")%>">
<table BORDER="0" WIDTH="948">
<tr>
<td align="left">第 <%=StartPos%>-<%=EndCount%>条记录, 共<%=TotalRec.item(0).text%> 条记录</td>
</tr>
</table>
<table BORDER="1" CELLSPACING="0"CELLPADDING=" 0" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#ffffff">
<tr bgcolor="#C1E0FF" align="center">
<td ALIGN="center" nowrap HEIGHT="20"> <%=Env_conm("StruSerial","结构编号")%> </td>
<td ALIGN="center" nowrap HEIGHT="20"> <%=Env_conm("SerialName","编号简称")%> </td>
<td ALIGN="center" nowrap HEIGHT="20"> <%=Env_conm("AcctId","账号")%> </td>
<td ALIGN="center" nowrap HEIGHT="20"> <%=Env_conm("DepId","机构号")%> </td>
</tr>
<% For i=0 To (AcctName.length -1) %> <tr> <td WIDTH="7%" ALIGN="center" HEIGHT="20"> <%=StruSerial.item(i).text%> </td>
<td WIDTH="7%" ALIGN="center" HEIGHT="20"> <%=SerialName.item(i).text%> </td>
<td WIDTH="7%" ALIGN="center" HEIGHT="20"> <%=AcctId.item(i).text%> </td>
<td WIDTH="7%" ALIGN="center" HEIGHT="20"> <%=DepId.item(i).text%> </td>
</tr>
<%next%>
</table>
<table name=table2 id=table2 BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="948" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#ffffff">
<tr>
<td>
<%
if (cdbl(TotalRec.item(0).text) mod cdbl(ExpRecCount)) then
LastPage = ( cdbl(TotalRec.item(0).text) - (cdbl(TotalRec.item(0).text) mod cdbl(ExpRecCount))) / cdbl(ExpRecCount)
else
LastPage = cdbl(cdbl(TotalRec.item(0).text) / cdbl(ExpRecCount) - 1 )
end if
%>
<%if StartPos<>"1" then%> <a href="javascript:firstpage(1,document.form1.action);"><img src="../../images/<%=conm_pic("btn_dyy.gif")%>" width="50" height="22" border="0"></a>
<a href="javascript:previouspage(<%=StartPos%>,document.form1.action);"><img src="../../images/<%=conm_pic("btn_syy.gif")%>" width="50" height="22" border="0"></a>
<%
end if
if (TotalRec.item(0).text-StartPos)>=ExpRecCount then
%>
<a href="javascript:nextpage(<%=StartPos%>,document.form1.action);"><img src="../../images/<%=conm_pic("btn_xyy.gif")%>" width="50" height="22" border="0"></a>
<a href="javascript:lastpage(<%=LastPage%>,document.form1.action);"><img src="../../images/<%=conm_pic("btn_zhyy.gif")%>" width="50" height="22" border="0"></a>
<%end if%>
</td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
Function pagebar( pagecount,page )
Dim i,ppage,str
str=" "
If request.querystring("page")<>"" Then
page=request.querystring("page")
End If If CInt(page)=1 Then
str=str&"<font color=""#FF7300""><b>1</b></font> "
Else
str=str&"<a href=""?page=1"">1</a> "
End If For i=0 To 3
ppage=CInt(page)-3+i
If i=0 And CInt(ppage)>2 Then
str=str&"... "
End If
If CInt(ppage)>1 And CInt(ppage)<CInt(pagecount) Then
If i=3 Then
str=str&"<b><font color=""#FF7300"">"&ppage&"</font></b> "
Else
str=str&"<a href=""?page="&ppage&""">"&ppage&"</a> "
End If
End If
Next For i=1 To 3
ppage=CInt(page)+i
If CInt(ppage)>1 And CInt(ppage)<Cint(pagecount) Then
str=str&"<a href=""?page="&ppage&""">"&ppage&"</a> "
End If
If i=3 And CInt(ppage)<CInt(pagecount)-1 Then
str=str&"... "
End If
Next If CInt(pagecount)<>1 Then
If CInt(page)=CInt(pagecount) Then
str=str&"<font color=""#FF7300""><b>"&pagecount&"</b></font> "
Else
str=str&"<a href=""?page="&pagecount&""">"&pagecount&"</a> "
End If
End If
str=str&"<br><a href=""?page=1"">首页</a> " If CInt(page)>1 Then
str=str&"<a href=""?page="&page-1&""">上一页</a> "
Else
str=str&"上一页 "
End If If CInt(page)<CInt(pagecount) Then
str=str&"<a href=""?page="&page+1&""">下一页</a> "
Else
str=str&"下一页 "
End If str=str&"<a href=""?page="&pagecount&""">尾页</a> "
pagebar=str
End Function
%><%=pagebar(20,2)%>