Results 1 to 10 of 10

Thread: Problem with an image src swapping scripting.

  1. #1
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with an image src swapping scripting.

    Hello there,

    I am using a script to display my business's portfolio. The intent is for potentual clients to view examples of our work in an easy, hassle free manner. As you'll see when you take a look at the page so far, the 1, 2, 3, etc links work as intended but the next and back scripts aren't working. The problem seems rather simple to fix but I'm not too terrible familiar with javascript so I'm not recognizing the error.

    Any help is greatly appreciated.

    Website: http://www.wesruvalcaba.com/occhi/index6.htm

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

    Default

    Doesn't work at all in FX1.5.0.4.
    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
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Doesn't work at all in FX1.5.0.4.
    That's what I'm using as well. Only "1" and "2" work right now. I've not added anymore content, otherwise, 3 - 15 would be functioning correctly as well. Regardless, the next and back commands aren't working properly. I've been messing with this script for the past half an hour even after posting this thread and I can't seem to get it to work. Ugh, frustration.

  4. #4
    Join Date
    Jul 2006
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    only one and 2 work in ie7.

  5. #5
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Still need help. Buuuuuuuuuuuump.

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

    Default

    Frankly, I'm amazed that works at all. Also, it's considerably overcomplicated.
    Code:
    <script type="text/javascript">
    Number.prototype.toDigits(n, r) {
      var s = this.toString(r ? r : 10);
      while(s.length < n)
        s = "0" + s;
      return s;
    }
    
    var count = 1,
      MyImages = new Array();
    for(var i = 1; i <= 15; ++i)
      (MyImages[i] = new Image()).src = "examples/page" + i.toDigits(2) + ".jpg";
    
    function loadImg(elName, img) {
      var imgNum = parseInt(img);
      if(!isNaN(imgNum)) document.images[elName].src = MyImages[count = imgNum].src;
      else
        for(var i = 0; i < MyImages.length; ++i)
          if(MyImages[i].src == img) {
            count = i;
            document.images[elName].src = img;
            break;
          }
    }
    
    function imgNext() {
      if (count < MyImages.length - 1) loadImg(++count);
      else loadImg(count = 1);
    }
    
    function imgBack() {
      if (count > 1) loadImg(--count);
      else loadImg(count = MyImages.length - 1);
    }
    </script>
    
    <!-- ... stuff ... -->
    
    <a class="pglink">|&lt;</a><a class="pglink" href="javascript:imgBack()">&lt;</a>
    <a class="pglink" href="examples/page01.jpg" onclick="loadimg('workImage', this.href); return false;">1</a>
    <!-- ... et cetera ... -->
    <a class="pglink" href="javascript:imgNext()">&gt;</a>
    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!

  7. #7
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Frankly, I'm amazed that works at all. Also, it's considerably overcomplicated.
    Thanks. It doesn't seem to work properly, though. Rather than swapping the image src, it redirects to just the image src alone when you click on 1 - 15. Back and next commands don't work a all either.

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

    Default

    Demo?
    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!

  9. #9
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Demo?
    http://www.wesruvalcaba.com/occhi/index7.html

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

    Default

    Ah, my error.
    Code:
    Number.prototype.toDigits = function(n, r) {
      var s = this.toString(r ? r : 10);
      while(s.length < n)
        s = "0" + s;
      return s;
    }
    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!

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
  •