Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with image gallery script - stops at 10th image

    Hi I've been trying to use a bit of script posted on a forum for a simple image gallery with back/next buttons and thumbnails. Looks great and nearly works, but have played and searched and cant for the life of me work out why it wont work after image 10. Theres also a small problem with the first thumbnail not working normally. Can anyone help?

    The original script was this
    http://misc.nickbrokeit.net/devshed/polo_o/

    and this is my best effort so far (script pasted below)
    http://www.mikesteel.co.uk/new/folio10.htm

    Really appreciate any help, once i can crack this I'll be able to finish redoing my site (www.mikesteel.co.uk) - ive already got the front done with some useful javascript:
    http://www.mikesteel.co.uk/new/new.htm

    thanks + have a great weekend
    Mike

    Code:
    <script type="text/JavaScript">
    function showPic(p)
    {
    var m=document.getElementById('mainPic');
    var p=document.getElementById('pic'+p);
    for (var i=1; i<=18; i++) document.getElementById('pic'+i).border="1";
    p.border="1";
    m.src=p.src;
    m.name=p.id;
    }
    function showPrev()
    {
    var m=document.getElementById('mainPic');
    var current=m.name.charAt(3)*1;
    var next=(current==1)?18:current-1;
    m.src="image"+next+".jpg";
    m.name="pic"+next;
    for (var i=1; i<=18; i++) document.getElementById('pic'+i).border="1";
    document.getElementById('pic'+next).border="1";
    }
    function showNext()
    {
    var m=document.getElementById('mainPic');
    var current=m.name.charAt(3)*1;
    var next=(current==18)?1:current+1;
    m.src="image"+next+".jpg";
    m.name="pic"+next;
    for (var i=1; i<=18; i++) document.getElementById('pic'+i).border="1";
    document.getElementById('pic'+next).border="1";
    }
    </script>

  • #2
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    if it goes through 9 images and fails on the tenth, one of two things is happening (imo)

    either there is a slight problem with image #10 itself... easily testible by changing the image it loads and seeing if it still fails... or theres something wrong in the script whereby the number 10 is causing a prob (unlikely)

    toss the code for your images and we'll be able to reproduce the problem
    Last edited by canadianjameson; 06-04-2005 at 05:07 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #3
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    i take that back, the problem isnt with the pic.

    it seems that any pic over the # of 9 doesnt work with the previous / forward buttons.

    what about a number with more that one digit would cause these functions to fail?

    Code:
    function showPrev()
    {
    	var m=document.getElementById('mainPic');
    	var current=m.name.charAt(3)*1;
    	var next=(current==1)?18:current-1;
    	m.src="image"+next+".jpg";
    	m.name="pic"+next;
    	for (var i=1; i<=18; i++) document.getElementById('pic'+i).border="1";
    	document.getElementById('pic'+next).border="1";
    }
    function showNext()
    {
    	var m=document.getElementById('mainPic');
    	var current=m.name.charAt(3)*1;
    	var next=(current==18)?1:current+1;
    	m.src="image"+next+".jpg";
    	m.name="pic"+next;
    	for (var i=1; i<=18; i++) document.getElementById('pic'+i).border="1";
    	document.getElementById('pic'+next).border="1";
    }
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #4
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    i see it now:

    Code:
    var next=(current==1)?18:current-1
    you have 18 images... everytime you go up by 1, :current-1 goes down by 1!

    18 - 9 = 9, and the script fails because it gets two 9's (if next = 9 but current = 9... what do you do.

    a quick workaround might be to either remove or add an image (lemme know)
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #5
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey thanks - I've kept trying and finally got it to work

  • #6
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    what fixed it?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)


  •  

    Posting Permissions

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