Results 1 to 5 of 5

Thread: interactive page navigation ?

  1. #1
    Join Date
    Aug 2005
    Location
    Brig o' Turk, Scotland
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question interactive page navigation ?

    Hi,

    I've set up buttons for navigating to last and previous pages. For a quick jump to one of 103 pages, I could use a drop down box, but the result is a ridiculously long list.

    It would be smarter and more user-friendly to have a text box into which the user could type any number from 1-103 and click a button in order to be sent directly to the relevant page (the sort of thing you see at the bottom of the Adobe reader, where you can type in a page number and be sent straight there).

    I've been trying to find something that would do this, but have not really known what to look for.

    Hope someone can guide me. Thanks.

    Riseard

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Something like this?
    Code:
    <script type="text/javascript">
    function go() {
      // number of pages
      var numPages = 103;
    
      var page = parseInt(document.getElementById("page").value);
      if((page !== page) || (page < 1) || (page > numPages)) {
        window.alert("Page does not exist.");
        document.getElementById("page").value = "";
        document.getElementById("page").focus();
      }
      else window.location = "page" + page + ".htm";
    }
    </script>
    <input type="text" size="3" id="page"/><button onclick="go();">Go!</button>
    Can you check for NaN directly like that in Javascript? In Java you need to use isNaN()...
    Last edited by Twey; 08-04-2005 at 02:07 PM. Reason: Added purty indentation.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,132
    Thanks
    44
    Thanked 3,229 Times in 3,190 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey
    Can you check for NaN directly like that in Javascript? In Java you need to use isNaN()...
    Not usually, I have no idea if it will work in this case (haven't tested it) but, probably not. All that test appears to do is compare the string "page" to the string "NaN". One shortcut is to do this:
    Code:
    if (page!==page)
    as NaN is the only thing not equal to itself.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah, thank you.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2005
    Location
    Brig o' Turk, Scotland
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Wow! It works. Thanks very much to you both.
    Riseard

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
  •