`
xurichusheng
  • 浏览: 335698 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

ibatis 分页 06_page1.js

阅读更多

page1.js

 

$(document).ready(function(){
	//选择第n页下拉框
	$("#select_page").change(function(){
	
		var rows = $("#rows").val();
		var pre = $("#select_page option:selected").val();
		var total = $("#total").val();
		
		rows = $.trim(rows);
		total = $.trim(total);
		
		rows = Number(rows);
		total = Number(total);
		
		var reg = /^[0-9]{1,}$/;
		
		if(!reg.exec(rows)){
			alert("请输入正整数");
			return null;
		}
		
		if(rows==0 || rows<0){
			alert("必须大于0");
			return null;
		}
		
		if(rows > total){
			alert("不能大于总记录数");
			return null;
		}
		
		window.location = "getUsersPage.action?pre="+pre+"&rows="+rows;
	});
	
	//输入每页显示的行数,点击"go"按钮
	$("#go_btn").click(function(){
	
		var total = $("#total").val();		
		var rows = $("#rows").val();
		
		rows = $.trim(rows);
		total = $.trim(total);
		
		rows = Number(rows);
		total = Number(total);
		
		var reg = /^[0-9]{1,}$/;
		
		if(!reg.exec(rows)){
			alert("请输入正整数");
			return null;
		}
		
		if(rows==0 || rows<0){
			alert("必须大于0");
			return null;
		}
		
		if(rows > total){
			alert("不能大于总记录数");
			return null;
		}
		
		window.location = "getUsersPage.action?pre=1&rows="+rows;
		
	});
});

/**
 * 分页
 */

//上一页
function topr(obj){
	
	var pre = obj.href.split('#')[1];	
	var rows = $("#rows").val();
	var total = $("#total").val();
	
	rows = $.trim(rows);
	total = $.trim(total);
	
	rows = Number(rows);
	total = Number(total);
	
	var reg = /^[0-9]{1,}$/;
		
	if(!reg.exec(rows)){
		alert("请输入正整数");
		return null;
	}
	
	if(rows==0 || rows<0){
		alert("必须大于0");
		return null;
	}
	
	if(rows > total){
		alert("不能大于总记录数");
		return null;
	}
	
	if(pre != 0){
		
		window.location = "getUsersPage.action?pre="+pre+"&rows="+rows;
	}
	
}

//下一页
function tonx(obj){
	
	var pre = obj.href.split('#')[1];	
	var rows = $("#rows").val();
	var total = $("#total").val();
	
	rows = $.trim(rows);
	total = $.trim(total);
	
	rows = Number(rows);
	total = Number(total);
	
	var reg = /^[0-9]{1,}$/;
		
	if(!reg.exec(rows)){
		alert("请输入正整数");
		return null;
	}
	
	if(rows==0 || rows<0){
		alert("必须大于0");
		return null;
	}
	
	if(rows > total){
		alert("不能大于总记录数");
		return null;
	}
	
	window.location = "getUsersPage.action?pre="+pre+"&rows="+rows;
}
 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics