Need Help: Javascript Div/Element Scroller

  • Howdy_McGee
  • Novice
  • Novice
  • Howdy_McGee
  • Posts: 16

Post 3+ Months Ago

Ok, So i'm making a script that will either scroll through a series of Divs or just 4 elements at a time when the user clicks on a "up/down arrow", right now though im set on making it scroll divs. I have started writing a script but i'm not too familiar with javascript and don't know where to go from there. Hoping some one here can help me somehow.

This is what I started working on.
Code: [ Select ]
var divScroll = [];

    divScroll[0] = document.getElementById('i1t5');
    divScroll[1] = document.getElementById('16t10');
    divScroll[2] = document.getElementById('i11t15');
    
function click()
{
    if (document.getElementById('arrowUp'))
    {
        for (int i = 0; i < divScroll.length; i--)
        {
            document.getElementById('leftScroll');
            
        }
    }
    if (document.getElementById('arrowDown'))
    {
        for (int i = 0; i < divScroll.size(); i++)
        {
            
        }
    }
}
  1. var divScroll = [];
  2.     divScroll[0] = document.getElementById('i1t5');
  3.     divScroll[1] = document.getElementById('16t10');
  4.     divScroll[2] = document.getElementById('i11t15');
  5.     
  6. function click()
  7. {
  8.     if (document.getElementById('arrowUp'))
  9.     {
  10.         for (int i = 0; i < divScroll.length; i--)
  11.         {
  12.             document.getElementById('leftScroll');
  13.             
  14.         }
  15.     }
  16.     if (document.getElementById('arrowDown'))
  17.     {
  18.         for (int i = 0; i < divScroll.size(); i++)
  19.         {
  20.             
  21.         }
  22.     }
  23. }


And I found this online that would probably give me a "scrolling" effect when clicked.
Code: [ Select ]
scrollStep=1

timerUp=""
timerDown=""

function toTop(id){
document.getElementById(id).scrollTop=0
}

function scrollDivDown(id){
clearTimeout(timerDown)
document.getElementById(id).scrollTop+=scrollStep
timerDown=setTimeout("scrollDivDown('"+id+"')",10)
}

function scrollDivUp(id){
clearTimeout(timerUp)
document.getElementById(id).scrollTop-=scrollStep
timerUp=setTimeout("scrollDivUp('"+id+"')",10)
}

function toBottom(id){
document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}

function stopMe(){
clearTimeout(timerDown)
clearTimeout(timerUp)
}
  1. scrollStep=1
  2. timerUp=""
  3. timerDown=""
  4. function toTop(id){
  5. document.getElementById(id).scrollTop=0
  6. }
  7. function scrollDivDown(id){
  8. clearTimeout(timerDown)
  9. document.getElementById(id).scrollTop+=scrollStep
  10. timerDown=setTimeout("scrollDivDown('"+id+"')",10)
  11. }
  12. function scrollDivUp(id){
  13. clearTimeout(timerUp)
  14. document.getElementById(id).scrollTop-=scrollStep
  15. timerUp=setTimeout("scrollDivUp('"+id+"')",10)
  16. }
  17. function toBottom(id){
  18. document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
  19. }
  20. function stopMe(){
  21. clearTimeout(timerDown)
  22. clearTimeout(timerUp)
  23. }


Any kind of help is appreciated, opinions, tips, tricks, anything that will help.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

maybe you should look at jQuery ...

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 74 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.