分享
 
 
 

ASP技巧:下拉菜单做翻页的通用代码

王朝asp·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

其实这个代码就是老外的那个翻页插件,后来是哪位好朋友(不好意思,忘了)修改后放在论坛上的,我还做成过插件,其实光是拷贝也挺方便的。还有最后一段是前后翻页的按钮,呵呵,这个还是ccjat提醒后加上的,用不用都随便咯。

<%

记录集名字_total = 记录集名字.RecordCount

If (记录集名字_numRows < 0) Then

记录集名字_numRows = 记录集名字_total

Elseif (记录集名字_numRows = 0) Then

记录集名字_numRows = 1

End If

记录集名字_first = 1

记录集名字_last = 记录集名字_first + 记录集名字_numRows - 1

If (记录集名字_total <> -1) Then

If (记录集名字_first > 记录集名字_total) Then 记录集名字_first = 记录集名字_total

If (记录集名字_last > 记录集名字_total) Then 记录集名字_last = 记录集名字_total

If (记录集名字_numRows > 记录集名字_total) Then 记录集名字_numRows = 记录集名字_total

End If

%>

<%

If (记录集名字_total = -1) Then

记录集名字_total=0

While (Not 记录集名字.EOF)

记录集名字_total = 记录集名字_total + 1

记录集名字.MoveNext

Wend

If (记录集名字.CursorType > 0) Then

记录集名字.MoveFirst

Else

记录集名字.Requery

End If

If (记录集名字_numRows < 0 Or 记录集名字_numRows > 记录集名字_total) Then

记录集名字_numRows = 记录集名字_total

End If

记录集名字_first = 1

记录集名字_last = 记录集名字_first + 记录集名字_numRows - 1

If (记录集名字_first > 记录集名字_total) Then 记录集名字_first = 记录集名字_total

If (记录集名字_last > 记录集名字_total) Then 记录集名字_last = 记录集名字_total

End If

%>

<%

Set MM_rs = 记录集名字

MM_rsCount = 记录集名字_total

MM_size = 记录集名字_numRows

MM_uniqueCol = ""

MM_paramName = ""

MM_offset = 0

MM_atTotal = false

MM_paramIsDefined = false

If (MM_paramName <> "") Then

MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")

End If

%>

<%

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

r = Request.QueryString("index")

If r = "" Then r = Request.QueryString("offset")

If r <> "" Then MM_offset = Int(r)

<%

MM_removeList = "&index="

If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="

MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

For Each Item In Request.QueryString

NextItem = "&" & Item & "="

If (InStr(1,MM_removeList,NextItem,1) = 0) Then

MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))

End If

Next

For Each Item In Request.Form

NextItem = "&" & Item & "="

If (InStr(1,MM_removeList,NextItem,1) = 0) Then

MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))

End If

Next

MM_keepBoth = MM_keepURL & MM_keepForm

if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)

if (MM_keepURL <> "") Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)

if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

Function MM_joinChar(firstItem)

If (firstItem <> "") Then

MM_joinChar = "&"

Else

MM_joinChar = ""

End If

End Function

%>

<%

MM_keepMove = MM_keepBoth

MM_moveParam = "index"

If (MM_size > 0) Then

MM_moveParam = "offset"

If (MM_keepMove <> "") Then

params = Split(MM_keepMove, "&")

MM_keepMove = ""

For i = 0 To UBound(params)

nextItem = Left(params(i), InStr(params(i),"=") - 1)

If (StrComp(nextItem,MM_moveParam,1) <> 0) Then

MM_keepMove = MM_keepMove & "&" & params(i)

End If

Next

If (MM_keepMove <> "") Then

MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)

End If

End If

End If

If (MM_keepMove <> "") Then MM_keepMove = MM_keepMove & "&"

urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = urlStr & "0"

MM_moveLast = urlStr & "-1"

MM_moveNext = urlStr & Cstr(MM_offset + MM_size)

prev = MM_offset - MM_size

If (prev < 0) Then prev = 0

MM_movePrev = urlStr & Cstr(prev)

%>

<script language="JavaScript">

function jumpage(selObj,restore){

eval("location='"+selObj.options[selObj.selectedIndex].value+"'");

if (restore) selObj.selectedIndex=0;}

</script>

<select name="pages" size=1 onChange="jumpage(this,0)" class="txtfld">

<%

TM_counter = 0

For i = 1 to 记录集名字_total Step MM_size

TM_counter = TM_counter + 1

TM_PageEndCount = i + MM_size - 1

if TM_PageEndCount > 记录集名字_total Then TM_PageEndCount = 记录集名字_total

if i <> MM_offset + 1 then

%>

<option value="<%=Request.ServerVariables("URL") & "?" & MM_keepMove & "offset=" & i-1 %>">

第 <%= TM_counter %> 页</option>

<% else %>

<option selected>第 <%=TM_counter%> 页</option>

<% End if %>

<% next %>

</select>

<input type="button" class="INPUT" onclick="location.href='<%=MM_movePrev%>'" value="|" style="FONT-FAMILY: 'Wingdings 3'" <% If MM_offset <> 0 Then

response.write ""

else

response.write "disabled"

end if %>>

<input type="button" class="INPUT" onclick="location.href='<%=MM_moveNext%>'" value="}" style="FONT-FAMILY: 'Wingdings 3'" <% If Not MM_atTotal Then

response.write ""

else

response.write "disabled"

end if %>>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有