Long article paging code

Source: Internet
Author: User

Use hr as a paging character during warehouse receiving, and replace Add the mark in the header and end of the warehouse receiving article
<! -- $ Pages $ -->
For example:
Dim str;
Str = trim (request ("textareaid "));
Str = "<! -- $ Pages $ --> "+ str +" <! -- $ Pages $ -->"
Str = Replace (str, str, "Import the database to the database, and everything will be done.

Code:

<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
<Style type = "text/css">
<! --
Div {font-size: 14px ;}
-->
</Style>
</Head>

<Body>
<Textarea name = "" cols = "" rows = "" id = "conpage" style = "display: none;">
<! -- $ Pages $ -->
Hi!
<! -- $ Pages $ -->
Hi!
<! -- $ Pages $ -->
He or she
<! -- $ Pages $ -->
All good
<! -- $ Pages $ -->
</Textarea>
<Script language = "javascript">
Var zhenze =/[^ 0-9]/; // create a regular expression, indicating a non-numeric string
Var thispage = document. getElementById ("conpage"). value; // get the content
Var page_amount, x;
Page_amount = thispage. split ('<! -- $ Pages $ --> '). length;
Page_amount --; // The number of $ pages $ IN THE CONTENT
Var asarray = new Array (); // Array
Var v = 0;
For (var t = 0; t <page_amount; t ++ ){
Asarray [t] = thispage. indexOf ("<! -- $ Pages $ --> ", v); // records the location of each $ pages $
V = asarray [t];
V ++;
};
Page_amount --;
For (var s = 0; s <page_amount; s ++ ){
// Write all the content in Segments
Document. write ('<div id = "pg' + (s + 1) + '" style = "block"> ');
Document. write (thispage. substring (asarray [s], asarray [s + 1]);
Document. write ('</div> ');
Alert (s + 1 );
};


Var obj, objt;
Var s_a_d = 1; // the id of the currently displayed page number. The default value is 1st. When showpage is set, this variable is used to record the page number displayed last time,
Function hidpage (hidt) {// This function is used to hide pages.
Obj = eval ("document. getElementById ('pg" + hidt + "')");
Obj. style. display = "none ";
};

Function showpage (sow) {// This function is used to display the number of pages
Obj = eval ("document. getElementById ('pg" + sow + "')");
Objt = eval ("document. getElementById ('pg" + (s_a_d) + "')"); // This sentence is used to obtain the page number displayed last time.
Objt. style. display = "none"; // hide the last page number
Obj. style. display = "block"; // display the page number to be displayed by the current user.
S_a_d = sow;
Document. getElementById ("pageamo"). value = sow;
Alert ("current display page" + s_a_d + "page ");
};

Var tts;
Function goto () {// page steering function, which is used to input the page number in the text box and then
Tts = document. getElementById ("inputpage"). value;
If (! Tts. match (zhenze) = ""){
Alert ("error, you have entered a non-numeric character ");
Return;
};
If (tts> page_amount | tts <1 ){
Alert ("this page is not available"); // illegal input all inspection completed
} Else {
Showpage (tts); // valid execution redirection
};
};


Document. write ('<div> ');
Document. write ('you are currently in the <input type = "button" id = "pageamo" value = "'+ s_a_d +'" style = "font-size: 12px; height: 18px; background-color: # FFFFFF; color: red; font-weight: bold; border: # FFFFFF 0px solid; "> page'); // indicates the current page number
Document. write ('total '+ page_amount + 'page'); // the total number of pages.
For (var k = 0; k <page_amount; k ++ ){
Document. write ('<a href = "javascript: showpage (' + (k + 1) + ')" style = "text-decoration: none;"> ');
Document. write ("[" + (k + 1) + "]");
Document. write ('</a> ');
Hidpage (k + 1); // hide all pages
}; // For: 1 2 3 4 5 ....
Showpage (1); // first display the content on the first page
Document. write ('to <input type = "text" id = "inputpage" style = "width: 20px; font-size: 12px; height: 18px; "value =" "> page'); // turn to form
Document. write ('<input type = "button" value = "Go" onclick = "goto ()" style = "height: 20px;"> ');
Document. write ('</div> ');
</Script>
</Body>
</Html>

Related Article

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.