⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajax分页查询程序 - ajax - 4s资讯社--分享与交流.htm

📁 自己做项目时做的一个javascript的分页例子
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0046)http://www.4studio.cn/www/42/2008-04/2418.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META 
content="4s,4studio,4s资讯社,4s it资讯,IT信息,分享互相网,网站运营,Web2.0,推广优化,建站心得,网络创业,策划盈利,电子商务" 
name=keywords>
<META content=4s资讯社--收集网络上热门的IT信息,提供分享与交流的平台,让大家在此找到快乐!! name=description><LINK 
href="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/style.css" type=text/css 
rel=stylesheet>
<SCRIPT language=javascript 
src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/select_card.js" 
type=text/javascript></SCRIPT>
<LINK title=RSS href="http://www.4studio.cn/rss.php?cid=42" 
type=application/rss+xml rel=alternate><LINK href="favicon.ico" 
type=image/x-icon rel=icon><LINK href="favicon.ico" type=image/x-icon 
rel="shortcut icon">
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY><!--BEGIN container-->
<DIV class=container><!--BEGIN HEADER-->
<DIV class=header>
<DIV class=header_top><ACRONYM class=acronym_11><A 
href="http://www.4studio.cn/">http://www.4studio.cn/</A></ACRONYM> <SPAN><A 
onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.4studio.cn/');" 
href="http://www.4studio.cn/#">设为首页</A> | <A href="http://www.4studio.cn/blog/" 
target=_blank>4studio博客</A> | <A href="http://www.4studio.cn/rss_map.html" 
target=_blank>RSS订阅</A> </SPAN></DIV>
<DIV class=header_main>
<DIV class=header_fix>
<UL>
  <LI id=li_1><IMG src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/logo.gif" 
  border=0> </LI>
  <LI id=li_3>
  <SCRIPT language=javascript 
  src="Ajax分页查询程序 - AJAX - 4s资讯社--分享与交流.files/468_60.js"></SCRIPT>
  </LI></UL>
<DIV class=header_nav>&nbsp;<A href="http://www.4studio.cn/">首页</A> <A 
href="http://www.4studio.cn/www/1/index.html">IT互联</A> <A 
href="http://www.4studio.cn/www/69/index.html">Web2.0</A> <A 
href="http://www.4studio.cn/www/23/index.html">推广优化</A> <A 
href="http://www.4studio.cn/www/72/index.html">网络创业</A> <A 
href="http://www.4studio.cn/www/25/index.html">策划盈利</A> <A 
href="http://www.4studio.cn/www/26/index.html">建站心得</A> <A 
href="http://www.4studio.cn/www/73/index.html">站长故事</A> <A 
href="http://www.4studio.cn/www/82/index.html">Windows Server 2008</A> <A 
href="http://www.4studio.cn/www/70/index.html">电子商务</A> <A 
href="http://www.4studio.cn/www/75/index.html">原创天地</A> <A 
href="http://www.4studio.cn/www/76/index.html">分享</A> </DIV>
<DIV class=header_search>
<DIV class=hot_search>热门关键词: <A href="http://www.4studio.cn/tag.php?Web2.0" 
target=_blank>Web2.0</A>&nbsp;&nbsp;<A href="http://www.4studio.cn/tag.php?Ajax" 
target=_blank>Ajax</A>&nbsp;&nbsp;<A href="http://www.4studio.cn/tag.php?CSS" 
target=_blank>CSS</A>&nbsp;&nbsp;<A 
href="http://www.4studio.cn/tag.php?%E6%8E%A8%E5%B9%BF" 
target=_blank>推广</A>&nbsp;&nbsp;<A href="http://www.4studio.cn/tag.php?PHP" 
target=_blank>PHP</A>&nbsp;&nbsp;<A 
href="http://www.4studio.cn/tag.php?%E5%88%9B%E4%B8%9A" 
target=_blank>创业</A></DIV>
<DIV class=search_form>
<FORM action=search.php method=post><SPAN><INPUT class=search_input id=keyword 
name=keyword><INPUT id=s_type type=hidden value=simple name=s_type><INPUT 
id=step type=hidden value=2 name=step></SPAN> <SPAN><INPUT class=search_button type=submit value="搜 索" border=0></SPAN> <INPUT 
id=mid type=hidden value=1 name=mid><!--value=1 即为新闻资讯内容模型--> 
</FORM></DIV></DIV></DIV></DIV></DIV><!--END HEADER--><!--BEGIN MAIN-->
<DIV class=main>
<DIV class=article_fix_height>
<DIV class=article_left>
<DIV class=article_main>
<DIV class=postion><A href="http://www.4studio.cn/">4s资讯社</A> &gt; <A 
href="http://www.4studio.cn/www/6/index.html">网络编程</A> &gt; <A 
href="http://www.4studio.cn/www/42/index.html">AJAX</A> </DIV>
<DIV class=article_title>Ajax分页查询程序</DIV>
<DIV class=article_info>作者: &nbsp; <ACRONYM class=acronym_11>2008-04-01 
21:55</ACRONYM> &nbsp; 来源: Ajax中国 &nbsp;</DIV>
<DIV class=tags>相关标签: <A href="http://www.4studio.cn/tag.php?%E5%88%86%E9%A1%B5" 
target=_blank>分页</A>&nbsp;&nbsp;<A href="http://www.4studio.cn/tag.php?AJAX" 
target=_blank>AJAX</A>&nbsp;&nbsp;<A 
href="http://www.4studio.cn/tag.php?%E7%A8%8B%E5%BA%8F" 
target=_blank>程序</A>&nbsp;&nbsp;<A 
href="http://www.4studio.cn/tag.php?%E6%9F%A5%E8%AF%A2" target=_blank>查询</A> 
</DIV>
<DIV class=prev_next><SPAN>&nbsp;&nbsp;&nbsp;<A title=ajax使用XMLHttpRequest与DOM对象 
href="http://www.4studio.cn/www/42/2008-03/2390.html">ajax使用XMLHttpRequest与DOM对象</A> 
<ACRONYM class=acronym_10>&gt;&gt; </ACRONYM></SPAN></DIV>
<DIV class=article_content id=content>
<DIV class=t_msgfont id=postmessage_6505>
<DIV class=blockcode>
<H5>&nbsp;</H5>
<H5><SPAN class=t_tag onclick=tagshow(event) 
href="tag.php?name=%B4%FA%C2%EB">代码</SPAN>:</H5><CODE id=code0>&lt;<SPAN 
class=t_tag onclick=tagshow(event) href="tag.php?name=div">div</SPAN> id="<SPAN 
class=t_tag onclick=tagshow(event) 
href="tag.php?name=div">div</SPAN>_trackpoint" style=" border:solid 1px gray; 
height:230px; width:99%; overflow-y:auto;"&gt;用于显示<SPAN class=t_tag 
onclick=tagshow(event) href="tag.php?name=%B2%E9%D1%AF">查询</SPAN>回的<SPAN 
class=t_tag onclick=tagshow(event) 
href="tag.php?name=%CA%FD%BE%DD">数据</SPAN>&lt;/<SPAN class=t_tag 
onclick=tagshow(event) href="tag.php?name=div">div</SPAN>&gt;<BR>&nbsp; &nbsp; 
&lt;div id="div_trackpages" style=" height:15px; width:99%; font-size:8pt; 
Word-break:break-all; word-wrap: break-word;"&gt;用于显示分页的页码&lt;/div&gt;&lt;br 
/&gt;<BR>&nbsp; &nbsp; &lt;div id="div_trackpagetab" style=" height:15px; 
width:99%; font-size:8pt; text-align:center;"&gt;用于显示前一页、后一页、...、<SPAN 
class=t_tag onclick=tagshow(event) 
href="tag.php?name=%CA%D7%D2%B3">首页</SPAN>、尾页等控制按钮&lt;/div&gt;<BR>&nbsp; &nbsp; 
&lt;div id="div_trackpage_status" style=" height:20px; width:99%; font-size:8pt; 
text-align:center;"&gt;用于显示当前页的页码&lt;/div&gt;<BR>&nbsp; &nbsp; 
实现客户端分页函数:<BR>&nbsp; &nbsp; var CurPage=0;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;//当前页<BR>&nbsp; &nbsp; var TotalPage=0;&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;//总页数<BR>&nbsp; &nbsp; var PageTab=7;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;//每组显示页数<BR>&nbsp; &nbsp; var CurTab=0;&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp; &nbsp;//当前分组<BR>&nbsp; &nbsp; </CODE></DIV>我的<SPAN class=t_tag 
onclick=tagshow(event) 
href="tag.php?name=%B3%CC%D0%F2">程序</SPAN>是设置每页显示50条数据,每组显示7页,这些可以按需求调整。<BR>&nbsp; 
&nbsp; TurnTab函数用于切换分组,根据传入的val来计算显示哪一组<SPAN class=t_tag onclick=tagshow(event) 
href="tag.php?name=%D2%B3%C3%E6">页面</SPAN>。val=1表示切换到下一组,val=-1表示切换到上一组,0表示切换到第一组,-2表示切换到最后一组。<SPAN 
class=t_tag onclick=tagshow(event) 
href="tag.php?name=%D3%C3%BB%A7">用户</SPAN>通过单击<SPAN class=t_tag 
onclick=tagshow(event) 
href="tag.php?name=%D2%B3%C3%E6">页面</SPAN>上的&nbsp;&nbsp;...&nbsp;&nbsp;符号来切换分组。&nbsp;&nbsp; 

<DIV class=blockcode>
<H5>代码:</H5><CODE id=code1>function TurnTab(val)<BR>{<BR>&nbsp; &nbsp; var nPage 
= 0;<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; if (val == 1) {<BR>&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;CurTab++;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;nPage = 
(CurTab - 1) * PageTab + 1;&nbsp;&nbsp;<BR>&nbsp; &nbsp; }<BR>&nbsp; &nbsp; else 
if (val == -1) {<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CurTab--;<BR>&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;nPage = (CurTab - 1) * PageTab + 1;<BR>&nbsp; 
&nbsp; }<BR>&nbsp; &nbsp; else if (val == 0) {<BR>&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;CurTab = 1;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;nPage = 
1;<BR>&nbsp; &nbsp; }<BR>&nbsp; &nbsp; else if (val == -2) {<BR>&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;CurTab = Math.floor(TotalPage / PageTab) + 
1;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;nPage = (CurTab - 1) * PageTab + 
1;<BR>&nbsp; &nbsp; }<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<BR>&nbsp; &nbsp; 
var carinfo = document.getElementById("div_trackpages");<BR>&nbsp; &nbsp; var 
tabinfo = document.getElementById("div_trackpagetab");<BR>&nbsp; &nbsp; var 
strInner = "";<BR>strInner += "&lt;a 
href=\"javascript:TurnPage(1)\"&gt;首页&lt;/a&gt; ";<BR>&nbsp; &nbsp; <BR>&nbsp; 
&nbsp; strInner += "&lt;a href=\"Javascript:PreviousPage()\"&gt;前一页&lt;/a&gt; 
";<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; strInner += "总共" + TotalPage + "页 
";<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; strInner += "&lt;a 
href=\"javascript:NextPage()\"&gt;下一页&lt;/a&gt; ";<BR>&nbsp; &nbsp; <BR>&nbsp; 
&nbsp; strInner += "&lt;a href=\"javascript:TurnPage(" + TotalPage + 
")\"&gt;尾页&lt;/a&gt; ";<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; tabinfo.innerHtml = 
strInner;<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; strInner = "";<BR>&nbsp; &nbsp; 
<BR>&nbsp; &nbsp; if (CurTab &gt; 1) strInner += "&lt;a 
href=\"javascript:TurnTab(-1)\"&gt;...&lt;/a&gt; ";<BR>&nbsp; &nbsp; <BR>&nbsp; 
&nbsp; for ( ; nPage&lt;=CurTab*PageTab; nPage++) {<BR>&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (nPage &lt;= 
TotalPage) {<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<BR>&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;strInner += "&lt;a 
href=\"javascript:TurnPage("+ nPage + ")\"&gt;"+nPage+"&lt;/a&gt; "<BR>&nbsp; 
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<BR>&nbsp; &nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;}<BR>&nbsp; &nbsp; }<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; if 
(nPage &lt; TotalPage) strInner += "&lt;a 
href=\"javascript:TurnTab(1)\"&gt;...&lt;/a&gt; ";<BR>&nbsp; &nbsp; <BR>&nbsp; 
&nbsp; carinfo.innerHTML = strInner;<BR>&nbsp; &nbsp; 
<BR>}</CODE></DIV>TurnPage函数用于切换分页,val表示要切换到的页数,根据要显示的页数生成查询范围,如查询前50条记录,从51到100的记录,从101到150的记录。。。<BR>&nbsp; 
&nbsp; cscCustomAnalyst是一个异步调用函数,函数实现的代码将在下面贴出。"Method","SID", "TIME1", "TIME2", 
"ROW1", "ROW2"都是执行查询所需的<SPAN class=t_tag onclick=tagshow(event) 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -