JS pagination on jstl value page

Source: Internet
Author: User

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 \ "> 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 \ "> Order No.: </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 \ "> transaction amount: </TD> ";
Invar = Invar + "<TD width = \" 70% \ "class = \" main_content_order_text \ ">" + accdiv (jsonlist [I]. orderamt, 100) + "RMB </TD> ";
Invar = Invar + "</tr> ";
Invar = Invar + "<tr> ";
Invar = Invar + "<TD width = \" 30% \ "class = \" main_content_order_name \ "> freight: </TD> ";
Invar = Invar + "<TD width = \" 70% \ "class = \" main_content_order_text \ ">" + accdiv (jsonlist [I]. postage, 100) + "RMB </TD> ";
Invar = Invar + "</tr> ";
Invar = Invar + "</table> <br> ";
}
$ ("# Mainpagediv" 2.16.html (Invar );
}
// Division
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 );
}
}
// Previous Page
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 );
}
// Next page
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 );
}

 

 

  1. $. Ajax ({
  2. URL: "Here is the address you want to request ",
  3. Data: {"ID": Id}, // in the form of a key/value pair
  4. Async: false,
  5. Datatype: "JSON ",
  6. Success: function (data ){
  7. For (INT I = 0; I <data. length; I ++) {// A JSON array passed through the loop background
  8. VaR datas = data [I];
  9. Alert (datas. firstname );
  10. Alert (datas. lastname );
  11. Alert (datas. Email );
  12. }
  13. }
  14. });

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.