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 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Is it possible to combine these two functions?

    Is it possible to combine these two functions?

    var thisPic = 0;

    function chgSlide(direction)
    {
    imgCt = slideChoice[0].length -1;
    if(document.images)
    {
    thisPic += direction;
    if(thisPic > imgCt)
    {
    thisPic = 0;
    }
    if(thisPic < 0)
    {
    thisPic = imgCt;
    }
    document.getElementById(slideID[0]).src = slideChoice[0][thisPic]
    }
    }

    function chgSlide1(direction)
    {
    imgCt = slideChoice[1].length -1;
    if(document.images)
    {
    thisPic += direction;
    if(thisPic > imgCt)
    {
    thisPic = 0;
    }
    if(thisPic < 0)
    {
    thisPic = imgCt;
    }
    document.getElementById(slideID[1]).src = slideChoice[1][thisPic]
    }
    }

  • #2
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var thisPic = 0;
    
    function chgSlide(direction,x)
    {
    imgCt = slideChoice[x].length -1;
    if(document.images)
    {
    thisPic += direction;
    if(thisPic > imgCt)
    {
    thisPic = 0;
    }
    if(thisPic < 0)
    {
    thisPic = imgCt;
    }
    document.getElementById(slideID[x]).src = slideChoice[x][thisPic]
    }
    }
    I think that works. Just pass in 0 or 1 for X.

  • #3
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks.


  •  

    Posting Permissions

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