jstl取值 页面js分页
var begin = 0;
var end = 3;
var page = 1;
var pagesize = 3;
var orderDetail = '${sessionScope.orderDetail}';
var jsonList = eval("("+orderDetail+")");
var length = jsonList.length;
if(length<=3){
$("#lastPage").hide();
$("#nextPage").hide();
end = length;
}
innerhtmlpage(begin,end);
function innerhtmlpage(begin,end){
var invar = "";
for(var i=begin;i<end;i++){
invar = invar+"<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
invar = invar+ "<tr>";
invar = invar+ "<td width=\"30%\" class=\"main_content_order_name\">订单名称:</td>";
invar = invar+ "<td width=\"70%\" class=\"main_content_order_text\">"+jsonList[i].orderName+"</td>";
invar = invar+ "</tr>";
invar = invar+ "<tr>";
invar = invar+ "<td width=\"30%\" class=\"main_content_order_name\">订单号:</td>";
invar = invar+ "<td width=\"70%\" class=\"main_content_order_text\">"+jsonList[i].orderId+"</td>";
invar = invar+ "</tr>";
invar = invar+ "<tr>";
invar = invar+ "<td width=\"30%\" class=\"main_content_order_name\">交易金额:</td>";
invar = invar+ "<td width=\"70%\" class=\"main_content_order_text\">"+accDiv(jsonList[i].orderAmt,100)+"元</td>";
invar = invar+ "</tr>";
invar = invar+ "<tr>";
invar = invar+ "<td width=\"30%\" class=\"main_content_order_name\">运费:</td>";
invar = invar+ "<td width=\"70%\" class=\"main_content_order_text\">"+accDiv(jsonList[i].postage,100)+"元</td>";
invar = invar+ "</tr>";
invar = invar+"</table><br>";
}
$("#mainPageDIV").html(invar);
}
//除法
function accDiv(arg1,arg2){
var t1=0,t2=0,r1,r2;
try{t1=arg1.toString().split(".")[1].length;}catch(e){}
try{t2=arg2.toString().split(".")[1].length;}catch(e){}
with(Math){
r1=Number(arg1.toString().replace(".","")) ;
r2=Number(arg2.toString().replace(".","")) ;
return (r1/r2)*pow(10,t2-t1);
}
}
//上一页
function lastPage1(){
if(page == 1){
var begin = 0;
var end = pagesize;
}else{
page = page - 1;
var begin = page*pagesize-pagesize;
var end = page*pagesize;
}
innerhtmlpage(begin,end);
}
//下一页
function nextPage1(){
if(page*pagesize-pagesize<length && length<=page*pagesize){
var begin = page*pagesize-pagesize;
var end = page*pagesize;
}else{
page = page + 1;
var begin = page*pagesize-pagesize;
var end = page*pagesize;
if(begin<length && length<end){
end = length;
}
}
innerhtmlpage(begin,end);
}
- $.ajax({
- url:"这里是你要请求的地址",
- data:{"id":id}, //以键/值对的形式
- async : false,
- dataType : "json",
- success : function(data) {
- for(int i = 0; i < data.length; i++) { //循环后台传过来的Json数组
- var datas = data[i];
- alert(datas.firstName);
- alert(datas.lastName);
- alert(datas.email);
- }
- }
- });