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.
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++)
{
}
}
}
- 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++)
- {
-
- }
- }
- }
And I found this online that would probably give me a "scrolling" effect when clicked.
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)
}
- 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)
- }
Any kind of help is appreciated, opinions, tips, tricks, anything that will help.