发个网站 大家给个思路
http://www.jfyfdm.com/index.aspx 呵呵。你要的是什么思路 属于分页不变问题post提交的,只是页码部分没有直接的源码,通过源码里德PageCode('3','25','divpage','IndexList.aspx')函数设置的页码部分,找到这个函数问题就可以解决了
在http://www.jfyfdm.com/index.js理可以找到这个函数,//页码//Current当前页码
//Total总记录数
//得到页码的HTML
PageCode('3','25','divpage','IndexList.aspx');isnone('f','1',0);
function PageCode(current=3, Total=25, divId=divpage, urlStr=IndexList.aspx) {
//当前页码的前后页码数
var k = 5;//每页显示页码数的-1的一半
var PageStr = "";//页码字符串
current = isNaN(current) || (typeof current) == 'undefined' ? 1 : parseInt(current);//当前页
//根据当前页显示的显示页码数目,获取数据。
var beginCode = Math.max(1, current - k);//每页显示的开始页码
var endCode = Math.min(Math.max(current + k, k * 2 + 1), Total);//显示的结束页码
if (current > 1) {//非第一页
PageStr += "<a style='cursor:pointer' pageCode='" + (current - 1) + "' >上一页 </a>";//上一页
}
for (var i = beginCode; i < endCode + 1; i++) {
PageStr += ("<a style='cursor:pointer' pageCode='" + i + "' > " + i + " </a>");//生成中间页码
}
if (current < endCode) {
PageStr += "<a style='cursor:pointer' pageCode='" + (current + 1) + "'> 下一页</a>";//下一页
}
//PageStr += "到第<input name='input2' type='text' class='pageinput' size='4' maxlength='8' id='pageIndexInput' /><input type='button' class='pagebtn' value='确定'pageCode='1'id='pagebtn' />";
$("#" + divId).html(PageStr);//
//设置当前页样式
var aCount = $("#" + divId + " a").size();//获得id为divId的层,就是页码的容器层下的a连接
if (aCount > 0) {
$("#" + divId + " a").each(function() {//
var pageCodeValue = $(this).attr("pageCode");
if (pageCodeValue == current) {//当前页设置背景色
$(this).css("color", "white");
$(this).css("background","#077ac7");
}
})
}
下面的是关键部分:
$("#" + divId + " a").bind("click", function() {//为页码的容器层下的a连接设置点击的处理函数
//这里加上事件函数
var current = $(this).attr("pageCode");//获得点击连接的pageCode的值,代表第几页
if($("#"+divId).children("#pageindex").length<1)//没有id 为pageindex的对象,新建
{
$("#"+divId).append("<input type='hidden' id='pageindex' name='pageindex'/>")//在页码的容器层下的加入name为pageindex的控件,代表分页
}
$("#pageindex").val(current);//设置请求的页码值
$("#ListForm").submit();//id为ListForm表单提交
//window.location.href = urlStr + "?us=fy&pageindex=" + current + "";
// return false;
});
}还有个isnone('f','1',0);也是有用的,它设置了ListForm表单中一些隐藏控件的值,搜索类型等以这个为例isnone('f','1',0)
function isnone(message,sta,aindex)
{
var vcontent="";//搜索结果的字符串
if(sta=="0")//没有搜索到数据
{
vcontent="没有关于<font color=\"red\">" + message + "</font>的任何记录,是否<a href=\"AddCompany.aspx\" >立即加入</a>";
}
else
{
vcontent="关于<font color=\"red\">" + message + "</font>的记录如下:"
}
$("#jieguo").html(vcontent);//
$("#seachword").val(message);//设置id为seachword的控件的值为message,这里是f,我搜的就是f,代表搜索的关键字
var alla=$(".option").eq(0).find("a");//这个地方是搜索的几个类型,公司,资讯,厂商办事处,电子书
var thisa=alla.eq(aindex);//取aindex=0的
alla.each(function(){
if($(this).attr("class")=="option_hover")//移除所有option_hover类的属性,加上option_not,即没有选上
{
$(this).removeAttr("class");
$(this).attr("class","option_not");
}
})
thisa.removeAttr("class");
thisa.attr("class","option_hover");//把选择的类型设置option_hover类
$("#seachtype").val(aindex);//id为seachtype的表单控件的值设置为aindex,这里是0,可以知道0公司,我搜索的是公司 1资讯 2厂商办事处3电子书
}再看这个提交表单<form name="ListForm" method="post" action="IndexList.aspx" id="ListForm" enctype="multipart/form-data">
里面的控件<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTczMDMyODkzM2RkCx9F4sqCLSyLZ7qZYuuwO/5JM9k=" />-------------post随机值
<input type="hidden" id="seachtype" name="seachtype" value="0" />-----搜索的类型0公司,1资讯 2厂商办事处3电子书
<input onfocus="
value="请输入要搜索的关键词" name="seachword" --------------------搜索的关键字
<input type='hidden' id='pageindex' name='pageindex'/>------------------js添加的,直接看不到,代表分页
由于是ASP的,所以无法用get提交,只能post,VIEWSTATE搜了下,也了解些作用 这个有点复杂 那位高手帮忙做个规则把 我是新手 学习学习 输入洛阳 把EMAIL 提出来给个规则学习学习 本帖最后由 zhouchanglin 于 2011-2-27 18:38 编辑
回复 5# huxiaoming168
搜洛阳的公司,中文要编码,是urlencode编码,你可以找到在线的网站,把要搜索的中文编码后,再在post数据里是编码的,要不是乱码,你可以点分页看抓到的post数据
,其中pageindex参数代表页码,只需要设置这个就行了
post数据:__VIEWSTATE=&seachtype=0&seachword=%E6%B4%9B%E9%98%B3&pageindex=[分页]
里面参数的意识
seachword --------------搜索的关键字,中文要urlencode编码
seachtype----------搜索类型 0公司,1资讯 2厂商办事处3电子书 谢谢 非常感谢ali68ls
页:
[1]