文件管理 · 2022年9月15日

网站分页代码|怎样用JS实现网站分页得到JS代码后如何使用

A. asp分页代码

<!–#includefile="conn.asp"–><styletype="text/css"><!–.STYLE3{font-family:"黑体";color:#999999;font-size:30px;}–></style><body><tablewidth="969"border="0"align="center"cellspacing="0"cellpadding="0"><tr><td><!–#includefile="top.asp"–></td></tr><tr><!—*********************88—–><td><%'这里提醒你一个问题,本来开始里这段代码是写在上面我打**号的地方,记住了如果当记录不存在的时候,你的页面就会变形,严格的根据框架来哦severid=request.QueryString("severid")pageid=request("s_id")'取得当前是第几页if(Cint(pageid)<=1)then'对其对行判断pageid=1endifsetrs=server.createobject("adodb.recordset")sql="select*fromppwhereseverid="&request.QueryString("severid")rs.opensql,conn,1,1ifnotrs.eofthen'这里要记录集的判断%><tablewidth="100%"border="0"cellspacing="0"cellpadding="0"><tr><tdwidth="225"height="50"align="left"valign="middle"class="STYLE3"><imgsrc="<%=trim(rs("diff1"))%>"/></td><tdwidth="18"rowspan="2"valign="bottom"><imgsrc="images/L.jpg"width="14"height="400"/></td><td></td></tr><tr><tdalign="left"valign="top"><%'fori=1tors.recordcount'response.write"<imgsrc="&trim(rs("simages"))&">"'ifrs.eofthenexitfor'rs.movenext'k=imod3'ifk=0then'response.write"<br>"'endif'next'以上为你写的代码,书写有很多地方不正确的,你看下我以下的代码%><!——————–><tablewidth="100%"border="0"cellspacing="0"cellpadding="0"><tr><td><%rs.pagesize=9'每页显示9条ifCint(pageid)>rs.pagecountthenpageid=rs.pagecountendifrs.absolutepage=pageidk=0fori=1tors.pagesizek=k+1response.write"<imgsrc="&trim(rs("simages"))&">"ifkmod3=0andk<>rs.pagesizethenresponse.write"<br>"endififrs.eofthenexitforrs.movenextnext%></td></tr><tr><tdalign="center">共<strong><%=rs.recordcount%></strong>条信息 每页显示<strong><%=rs.pagesize%></strong>条共<strong><%=rs.pagecount%></strong>页<%ifpageid=1then%><%else%><ahref="?s_id=1&severid=<%=severid%>">|<<</a><ahref="?s_id=<%=pageid-1%>&severid=<%=severid%>"><<</a><ahref="?s_id=<%=pageid-1%>&severid=<%=severid%>">[<%=pageid-1%>]</a><%endif%><%ifrs.pagecount=1then%><%else%>[<%=pageid%>]<%endif%><%ifrs.pagecount-pageid<>0then%><ahref="?s_id=<%=pageid+1%>&severid=<%=severid%>">[<%=pageid+1%>]</a><ahref="?s_id=<%=pageid+1%>&severid=<%=severid%>">>></a><ahref="?s_id=<%=rs.pagecount%>&severid=<%=severid%>">>>|</a><%endif%></td></tr></table><!—————————–></td><td><imgsrc="<%=trim(rs("bimages"))%>"/></td></tr></table><%endif%></td></tr><tr><td><!–#includefile="foot.asp"–></td></tr></table></body>

B. 如何在asp网站新闻中添加一个自动分页的代码

自动分页不好,会打乱网页布局的。手动分页我写了一个。<%acticlepage=int(Trim(request("acticlepage")))if acticlepage="" then acticlepage=0Set rs_aboutus = Server.CreateObject("ADODB.Recordset")sql="select Content from Aboutus"rs_aboutus.open sql,conn,1,3content=rs_aboutus("content")contentArry=split(content,"<SPAN id=page></SPAN>")'分页标志,一般在后台添加文章里,手动加到代码里.%> <% if ubound(contentArry)<1 then response.Write(content) else response.Write contentArry(acticlepage) response.Write("<hr><center>") if acticlepage=0 then response.Write "<a href=?Title="&Title&"&acticlepage="&acticlepage+1&">下一页</a>" else if acticlepage>=ubound(contentArry) then response.Write "<a href=?Title="&Title&"&acticlepage="&acticlepage-1&">上一页</a>" else response.Write "<a href=?Title="&Title&"&acticlepage="&acticlepage-1&">上一页</a>" response.Write "<a href=?Title="&Title&"&acticlepage="&acticlepage+1&">下一页</a>" end if end if response.Write("</center>") end if%><%rs.closeset rs=nothingrslist.closeset rslist=nothing%>注意事项,这是从我用的程序里复制出来的,你要作适当的修改。

C. 求asp分页代码,请给编剧一下下面的源码

已经完全给你写好了,请直接复制下面代码进行使用(注意,我的程序中所有的news.asp都要换成你的文件的文件名。如果你本页的文件名就叫news.asp的话就不用换啦)<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><% set conn=server.createobject("adodb.connection") conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db_sousuo1.mdb") %> <!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></head><body><table width="535" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="200" valign="top"> <% dim rs,sql set rs=server.CreateObject("adodb.recordset") sql="select * from proct where " if trim(request("bt"))<>"" then sql= sql & "carclass like '%"&trim(request("bt"))&"%' and " end if if trim(request("nr"))<>"" then sql= sql & "provice like '%"&trim(request("nr"))&"%' and " end if if trim(request("fbz"))<>"" then sql= sql & "provice_shi like '%"&trim(request("fbz"))&"%' and " end if sql= sql & " 1=1 " rs.open sql,conn,1 if rs.bof or rs.eof then response.write "对不起,没有符合查询条件的学生信息!" else dim page page=Clng(request("page")) rs.pagesize=20 if page<1 then page=1 if page>rs.pagecount then page=rs.pagecount rs.Absolutepage=page %> <% for i=1 to rs.pagesize %> <table height=24 cellspacing=0 cellpadding=0 width=535 border=0> <tbody> <tr bgcolor="#f7f7f7" onmouseover="this.bgColor='#e8e8e8';" onmouseout="this.bgColor='#f7f7f7';"> <td height="25" align="left"><%=i%>. <%=rs("carclass")%></td> </tr> </tbody> </table> <% rs.movenext if rs.eof then exit for next end if %></td> </tr> <tr> <td> <form name="form1" method="get" action="news.asp"><%Response.write "<span class='style1'>共找到</span>" & "<span class='style1'><font color='#FF0000'>" & Cstr(rs.RecordCount) & "</font></span>" & "<span class='style1'>名学生</span>  "if page<>1 thenresponse.write "<span class='style1'><a href=news.asp?page=1>首页</a> </span>"response.write "<span class='style1'><a href=news.asp?page="&(page-1)&">上一页</a></span> "end ifif page<>rs.pagecount thenresponse.write "<span class='style1'><a href=news.asp?page="&(page+1)&">下一页</a> </span>" response.write "<span class='style1'><a href=news.asp?page="&rs.pagecount&">尾页</a> </span>"end if%><span class='style1'>第<font color='#FF0000'><%=page%></font>页/共<font color='#FF0000'><%=rs.pagecount%></font>页  </span><input name="page" size="2" value="<%=page%>"><INPUT id=image type=image src="images/go.gif" border=0></form> </td> </tr> </table> </body></html>

D. 网页上的“上一页,下一页”js代码怎么写

需要准备的材料分别有:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建专html文件,例如:index.html。

E. 怎样用JS实现网站分页,得到JS代码后如何使用

你是要ajax?建议用ajax的框架,假如你是用java的 ajaxanywhere是个比较好的框架。net直接拖就行了。。纯版粹的js的分页那有什么权意义?数据不分页的话,数据都读到页面上了,你服务器内存不会溢出吗

F. 在网站后台编辑长篇文章时加入 什么简单代码可实现文章分页显示

在button的事件里写上自己的代码,当然就是直接insert innerhtml自己的分页标志了,我目前用的是|,|,|,|,|,|当然可以自定义其他的。首先提供个类库。1 ContentPager .csusing System;using System.Data;using System.Configuration;using System.Collections;using System.ComponentModel;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Web.SessionState;/// <summary>/// ContentPager 的摘要说明/// </summary>public class ContentPager : System.Web.UI.Page{ private System.Web.UI.WebControls.HyperLink lnknext; private System.Web.UI.WebControls.HyperLink lnkprev; private System.Web.UI.WebControls.HyperLink lnkfist; private System.Web.UI.WebControls.HyperLink lnklast; private System.Web.UI.WebControls.Label pagenum; private System.Web.UI.WebControls.Label pagecount; private System.Web.UI.WebControls.Label displaycontent; public ContentPager() { // // TODO: 在此处添加构造函数逻辑 // } public void datapager(string content,string query) { string PagerSplit = System.Configuration.ConfigurationManager.AppSettings["PagerSplit"];//从web.config中获取分页符,当然这里可以自己定义,为了方便还是放到配置文件或者数据库中。 string[] contentArray = StringSplit(content, PagerSplit);//这里是一个方法,摘自网上 int PageCount = contentArray.Length; this.pagecount.Text = "共<b><font color='#FF0000'>" + PageCount.ToString() + "</font></b>页"; int CurPage; //确定当前页数 if (System.Web.HttpContext.Current.Request.Params["Page"] != null) { CurPage = Convert.ToInt32(System.Web.HttpContext.Current.Request.Params["Page"]); } else { CurPage = 1; } if (CurPage < 1) CurPage = 1; if (Convert.ToInt32(System.Web.HttpContext.Current.Request.Params["Page"]) > PageCount) { CurPage = PageCount; } //显示当前页数 this.pagenum.Text = "第<b><font color='#FF0000'>" + CurPage.ToString() + "</font></b>页"; //下一页 if (CurPage != PageCount) { lnknext.NavigateUrl = System.Web.HttpContext.Current.Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1) + query; } //上一页 if (CurPage > 1) { lnkprev.NavigateUrl = System.Web.HttpContext.Current.Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage – 1) + query; } //第一页 if (CurPage != 1) { lnkfist.NavigateUrl = System.Web.HttpContext.Current.Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(1) + query; } //最后一页 if (CurPage != PageCount) { lnklast.NavigateUrl = System.Web.HttpContext.Current.Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(PageCount) + query; } displaycontent.Text = contentArray[CurPage – 1].ToString(); }#region System.Web.UI.WebControls.HyperLink DisplayContent public System.Web.UI.WebControls.Label DisplayContent { get { return this.DisplayContent; } set { this.displaycontent = value; } } #endregion #region System.Web.UI.WebControls.HyperLink Lnkprev public System.Web.UI.WebControls.HyperLink Lnkprev { get { return this.lnkprev; } set { this.lnkprev = value; } } #endregion #region System.Web.UI.WebControls.HyperLink Lnknext public System.Web.UI.WebControls.HyperLink Lnknext { get { return this.lnknext; } set { this.lnknext = value; } } #endregion #region System.Web.UI.WebControls.HyperLink Lnkfist public System.Web.UI.WebControls.HyperLink Lnkfist { get { return this.lnkfist; } set { this.lnkfist = value; } } #endregion #region System.Web.UI.WebControls.HyperLink Lnklast public System.Web.UI.WebControls.HyperLink Lnklast { get { return this.lnklast; } set { this.lnklast = value; } } #endregion #region System.Web.UI.WebControls.Label Pagenum public System.Web.UI.WebControls.Label Pagenum { get { return this.pagenum; } set { this.pagenum = value; } } #endregion #region System.Web.UI.WebControls.Label Pagecount public System.Web.UI.WebControls.Label Pagecount { get { return this.pagecount; } set { this.pagecount = value; } } #endregion #region 将字符串分割成数组 /// <summary> /// 将字符串分割成数组 /// </summary> /// <param name="strSource"></param> /// <param name="strSplit"></param> /// <returns></returns> public string[] StringSplit(string strSource, string strSplit) { string[] strtmp = new string[1]; int index = strSource.IndexOf(strSplit, 0); if (index < 0) { strtmp[0] = strSource; return strtmp; } else { strtmp[0] = strSource.Substring(0, index); return StringSplit(strSource.Substring(index + strSplit.Length), strSplit, strtmp); } } #endregion #region 采用递归将字符串分割成数组 /// <summary> /// 采用递归将字符串分割成数组 /// </summary> /// <param name="strSource"></param> /// <param name="strSplit"></param> /// <param name="attachArray"></param> /// <returns></returns> private string[] StringSplit(string strSource, string strSplit, string[] attachArray) { string[] strtmp = new string[attachArray.Length + 1]; attachArray.CopyTo(strtmp, 0); int index = strSource.IndexOf(strSplit, 0); if (index < 0) { strtmp[attachArray.Length] = strSource; return strtmp; } else { strtmp[attachArray.Length] = strSource.Substring(0, index); return StringSplit(strSource.Substring(index + strSplit.Length), strSplit, strtmp); } } #endregion}2 调用部分:在aspx中增加lable等元素。 <asp:label id="currentpage" runat="server" CssClass="gray">当前页</asp:label> <asp:label id="totalpage" runat="server" CssClass="gray">Label</asp:label> <asp:hyperlink id="lnkfist" runat="server" CssClass="gray">首页</asp:hyperlink>| <asp:hyperlink id="lnkprev" runat="server" CssClass="gray">前页</asp:hyperlink>| <asp:hyperlink id="lnknext" runat="server" CssClass="gray">下页</asp:hyperlink>| <asp:hyperlink id="lnklast" runat="server" CssClass="gray">尾页</asp:hyperlink>在aspx.cs中增加调用代码。 private ContentPager pager; protected void Page_Load(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["id"]);//接收参数,例如访问这个页是xxx.aspx?id=1 DataSet ds = new DataSet(); //从数据库读内容部分就略掉了 DataRow drow; drow = ds.Tables[0].Rows[0]; string cont = drow["content"].ToString();//此部分可以把内容中的HTML代码转换一下,我也省略了 //文章分页,关键部分 pager = new ContentPager(); pager.Lnknext = this.lnknext; pager.Lnkprev = this.lnkprev; pager.Lnklast = this.lnklast; pager.Lnkfist = this.lnkfist; pager.Pagenum = this.currentpage; pager.Pagecount = this.totalpage; pager.DisplayContent = this.content; string query = "&id=" + Request.QueryString["id"].ToString(); pager.datapager(cont, query);}

G. 怎样用JS实现网站分页,要最简单的

不多说,以下是代码<script language="javascript">var total=172; //总条目: 可变var show=20; //每页显示条目数: 可变total%show==0?page=total/show:page=Math.ceil(total/show); //计算总页数//取得当前页序号 – idxidx=window.location.search; //这里得到 ?0 字样if(idx=="") idx="?0"; //初始可能没有URL的尾部参数mylen=idx.length-1;idx=idx.substr(1,mylen);var title=new Array(); //测试用文章标题数组 title (赋值)for(i=0;i<total;i++) { k=i+1; title[i]="文章标题 " + k + "<br>";}function echostr(pg) { //函数: 打印各页内容 var mystr=""; for(i=0;i<show;i++) { myidx=pg*show+i; if(title[myidx]) mystr+=title[myidx]; //只显示存在的内容 } document.write(mystr);}//显示相关资料 – 测试用document.write('总条目: ' + total + '┊每页显示数: ' + show + '┊需要页数: ' + page + '┊当前页码序号(idx): ' + idx + '<br><br>');echostr(idx); //显示页面内容function pg_link(all){ //函数: 打印页码链接 linkstr="<br>第 "; for(i=0;i<all;i++) { j=i+1; i!=idx ? linkstr+="<a href='jspage.htm?" + i + "'>" + j + "</a> ":linkstr+=j + " "; } linkstr+="页"; document.write(linkstr + "<br><br>");}pg_link(page); //显示页码链接</script>

H. 一个网页实现分页

不清楚你的网站是用什么实现的,现在提供两种方法:一、动态网页:这里有一段PHP代码,供参考,我这边运行成功:1.显示内容部分<?php$page=$_GET["page"];if($page==""){$page=1;}if(is_numeric($page)){$page_size=30;$query="select count(*) as total from solution order by id desc";$result = mysql_db_query($dbn, $query);$message_count=mysql_result($result,0,"total");$page_count=ceil($message_count/$page_size);$offset=($page-1)*$page_size;$sql=mysql_db_query($dbn,"select * from solution order by id desc limit $offset,$page_size");$row=mysql_fetch_object($sql);if(!$row){echo("No data!");}?><?phpdo{?></p>+ pageurl; ?>.html" title="pagetitle; ?>">pagetitle; ?><?php}while($row=mysql_fetch_object($sql));?><?php}?>2.分页部分<?phpif($page!=1){echo "First ";echo "Previous ";}if($page<$page_count){echo "Next ";echo "End";}?> Current Page: / <?phpmysql_free_result($sql);?>二、静态网页用js:用JavaScript伪分页

I. html简单的分页代码怎么写

网页链接

看一下这个吧,现在很少有人手动写分页了,一专般都是用插件。或者现在主流的前属端框架,都有用户量特别大的前端组件库,用起来很方便。其实这个分页手写js并不难,主要是理清逻辑就可以了,能写但是没必要~如果是比较老的前端框架,必须手写js分页逻辑,追问就行,我给你屡屡

J. C#网站分页问题~~

就是gridview那个控件,他有个自动分页功能。如果你要自己写代码的话,建议看这个:GridView较之DataGrid提供了更加强大、更加完善的功能,而且具备了丰富的可扩展功能,可以使用GridView提供的pagertemplate自定义分页模板:事实上,GridView默认的几中分页样式,都是将相关按钮的CommandName设为Page,而CommandArgument设为相关参数,可接受的参数包括,first,last,prev,next,<PageIndex>(具体数字),然后按事件回溯,触发顶层的RowCommand,因此我们页可以使用这些默认的可识别的参数自定义自己的分页模板,asp.net会自动设置当前的NewPageIndex,而不需要任何的冗余代码。.aspx页面:<asp:gridview id="GridView1" runat="server" allowpaging="True" pagesize="10" autogeneratecolumns="False" datasourceid="SqlDataSource1" onpageindexchanging="GridView1_PageIndexChanging"> <columns> <asp:boundfield datafield="CompanyName" headertext="CompanyName" sortexpression="CompanyName" /> <asp:boundfield datafield="ContactTitle" headertext="ContactTitle" sortexpression="ContactTitle" /> <asp:boundfield datafield="Phone" headertext="Phone" sortexpression="Phone" /> <asp:boundfield datafield="Fax" headertext="Fax" sortexpression="Fax" /> <asp:boundfield datafield="ContactName" headertext="ContactName" sortexpression="ContactName" /> </columns> <pagertemplate> <table width="100%"> <tr> <td style="text-align:right"> 第<asp:Label id="lblPageIndex" runat="server" text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />页 共/<asp:Label id="lblPageCount" runat="server" text='<%# ((GridView)Container.Parent.Parent).PageCount %>' />页 <asp:linkbutton id="btnFirst" runat="server" causesvalidation="False" commandargument="First" commandname="Page" text="首页" /> <asp:linkbutton id="btnPrev" runat="server" causesvalidation="False" commandargument="Prev" commandname="Page" text="上一页" /> <asp:linkbutton id="btnNext" runat="server" causesvalidation="False" commandargument="Next" commandname="Page" text="下一页" /> <asp:linkbutton id="btnLast" runat="server" causesvalidation="False" commandargument="Last" commandname="Page" text="尾页" /> <asp:textbox id="txtNewPageIndex" runat="server" width="20px" text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' /> <asp:linkbutton id="btnGo" runat="server" causesvalidation="False" commandargument="-1" commandname="Page" text="GO" /><!– here set the CommandArgument of the Go Button to '-1' as the flag –> </td> </tr> </table> </pagertemplate> </asp:gridview> <asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="Data Source=.;Initial Catalog=Northwind;Integrated Security=True" providername="System.Data.SqlClient" selectcommand="SELECT [CompanyName], [ContactTitle], [Phone], [Fax], [ContactName] FROM [Customers]"> </asp:sqldatasource>PageIndexChanging处理程序: protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView theGrid = sender as GridView; // refer to the GridView int newPageIndex = 0; if (-2 == e.NewPageIndex) { // when click the "GO" Button TextBox txtNewPageIndex = null; //GridViewRow pagerRow = theGrid.Controls[0].Controls[theGrid.Controls[0].Controls.Count – 1] as GridViewRow; // refer to PagerTemplateGridViewRow pagerRow = theGrid.BottomPagerRow; //GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow//updated at 2006年6月21日3:15:33 if (null != pagerRow) { txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox; // refer to the TextBox with the NewPageIndex value } if (null != txtNewPageIndex) { newPageIndex = int.Parse(txtNewPageIndex.Text) – 1; // get the NewPageIndex } } else { // when click the first, last, previous and next Button newPageIndex = e.NewPageIndex; } // check to prevent form the NewPageIndex out of the range newPageIndex = newPageIndex < 0 ? 0 : newPageIndex; newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount – 1 : newPageIndex; // specify the NewPageIndex theGrid.PageIndex = newPageIndex; // rebind the control // in this case of retrieving the data using the xxxDataSoucr control, // just do nothing, because the asp.net engine binds the data automatically }