Results 1 to 10 of 10

Thread: Page change with pagination code activate

  1. #1
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Page change with pagination code activate

    1) Script Title: Ajax Pagination script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nate/index.htm

    3) Describe problem: I created 2 different pages (a.htm) and (b.htm). Both pages have the same ajax pagination script running on different categories.

    I also created a hyperlink in (a.htm) to connect to (b.htm), working fine.
    The problem is, my hyperlink in (a.htm) cannot call the function to jump to "pagination page 2" in (b.htm)

    Does anyone know how to?

    <a href="b.htm">
    <a href="javascript:mypages.selectpage(1)">

    Does not seems to work in this form. Is there anyway to combine this two?

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You'll need to pass some info via the URL or cookies to the target page containing the Pagination script to then tell it to run selectpage() with a certain value. The technique for doing this with another script is discussed here: http://www.dynamicdrive.com/forums/s...ad.php?t=24920

    In a nutshell though, instead of the default:
    Code:
    <script type="text/javascript">
    
    var myajaxbook={} //arbitrary variable to hold page settings for this book
    myajaxbook.page=["external.htm", "external2.htm", "external3.htm", "external4.htm"]
    myajaxbook.selectedpage=0 //set page shown by default (0=1st page)
    
    </script>
    You'd have this instead:

    Code:
    <script type="text/javascript">
    
    var param=window.location.href.match(/selectpage=(\d+)/i)
    var paramvalue=RegExp.$1
    if (/\d+/i.test(paramvalue)) //if URL parameter contains "?selectpage=integer"
    
    var myajaxbook={} //arbitrary variable to hold page settings for this book
    myajaxbook.page=["external.htm", "external2.htm", "external3.htm", "external4.htm"]
    var param=window.location.href.match(/selectpage=(\d+)/i)
    var paramvalue=RegExp.$1
    if (/\d+/i.test(paramvalue)) //if URL parameter contains "?selectpage=integer"
    myajaxbook.selectedpage=parseInt(paramvalue)
    else
    myajaxbook.selectedpage=0 //set page shown by default (0=1st page)
    
    </script>
    The link on page A would look something like the below:

    Code:
    <a href="b.htm?selectpage=1">

  3. #3
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thank you

    DD should have a tag line call "YOU JUST CAN"T BELIEVE YOUR EYES"

    I really cannot believe my eyes, it really works.

    Thank you so much.

    This problem has caught me a week (before i know DD). In just a day DD solved all of it.

    Really good job

  4. #4
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok now jumping to a page is not a problem, but calling another set of book is?

    Can you please show me how to call another set of book say (myajaxbook3) to load instead of showing the (myajaxbook) set when i call from an external url.

    Thank you

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    What "book" is loaded simply depends on how you configure it when it's called. So for example, you might have something like:

    Code:
    <script type="text/javascript">
    
    var param=window.location.href.match(/selectpage=(\d+)/i)
    var paramvalue=RegExp.$1
    if (/\d+/i.test(paramvalue)) //if URL parameter contains "?selectpage=integer"
    
    var myajaxbook3={} //arbitrary variable to hold page settings for this book
    myajaxbook3.page=["page1.htm", "page2.htm", "page3.htm"]
    var param=window.location.href.match(/selectpage=(\d+)/i)
    var paramvalue=RegExp.$1
    if (/\d+/i.test(paramvalue)) //if URL parameter contains "?selectpage=integer"
    myajaxbook3.selectedpage=parseInt(paramvalue)
    else
    myajaxbook3.selectedpage=0 //set page shown by default (0=1st page)
    
    </script>
    Here I'm creating a book with 3 pages, and either selecting the page based on the URL parameter, or the 1st page by default.

  6. #6
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    oops.. sorry i sould be more specific, i am just a beginner so sorry.
    Here:...

    I've created 3 books in url "z.htm" and in url "y.htm" i have 3 buttons,
    1) <a href="z.htm?selectbook=myajaxbook1">
    2) <a href="z.htm?selectbook=myajaxbook2">
    3) <a href="z.htm?selectbook=myajaxbook3"> respectively.

    so when i click on the button, it will call z.htm with the respective set of myajaxbook shown

    so what code should i insert down here:-
    <script type="text/javascript">

    var myajaxbook1={} //arbitrary variable to hold page settings for this book
    myajaxbook1.page=["page1.htm", "page2.htm", "page3.htm"]
    myajaxbook1.selectedpage=0 //set page shown by default (0=1st page)

    var myajaxbook2={} //arbitrary variable to hold page settings for this book
    myajaxbook2.page=["page1.htm", "page2.htm", "page3.htm"]
    myajaxbook2.selectedpage=0 //set page shown by default (0=1st page)

    var myajaxbook3={} //arbitrary variable to hold page settings for this book
    myajaxbook3.page=["page1.htm", "page2.htm", "page3.htm"]
    myajaxbook3.selectedpage=0 //set page shown by default (0=1st page)

    var mypages=new ajaxpageclass.bindpages(myajaxbook1, "pcontent", ["paginate-bottom"])

    </script>

    Thank you for your patient

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please format any code in your post using the CODE tag. This makes it a lot easier to read it.

    So are you actually looking to select a particular book via the URL parameter, or a particular page within a particular book as well? The code I had posted uses the URL parameter simply to select a particular page regardless of which book it's being used on. The code you posted:

    Code:
    1) <a href="z.htm?selectbook=myajaxbook1">
    2) <a href="z.htm?selectbook=myajaxbook2">
    3) <a href="z.htm?selectbook=myajaxbook3"> respectively.
    Are you really asking something like:

    Code:
    1) <a href="z.htm?selectbook=myajaxbook1&selectpage=1">
    2) <a href="z.htm?selectbook=myajaxbook2&selectpage=0">
    3) <a href="z.htm?selectbook=myajaxbook3&selectpage=2">
    ?

  8. #8
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry for the code. Anyway it's done. Thanks for your help

    But another thing is:-

    When i have a very large book say 200pages, then the pagination-link will be very long right?

    I am thinking is there anyway to display just
    << 1 2 3 4 5 6 7 8 9 10 Next>>
    So when i click 2
    the link become
    << 2 3 4 5 6 7 8 9 10 11 Next>>
    and when i click 3
    the link become
    << 3 4 5 6 7 8 9 10 11 12 Next>>
    and so on
    the pagination-link will always have 10 numbers or maybe 5 numbers display no matter how many pages i have

    is it possible

    example website -
    http://boardgamecafe.net/community/p...icture875.aspx

    which consist of < Previous 1 2 3 4 5 Next> only

    and if possible i would like to display the number of page of how many pages like this example: -
    "Page 3 of 911 (911 items)"

  9. #9
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Technically it's definitely possible, though the changes involved would be more than just a "Quick edit". The best I can do now is to consider adding this feature the next time the script is updated, probably in the next 3 weeks.

  10. #10
    Join Date
    Jun 2008
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Has the feature for controlling large number of pages been added?

    If so how do we implement this?

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •