Thought I would post the final results of this question. I used it to implement a scrolling div of thumbs on my photoblog. You can see it here. Two functions for the left and right buttons:
var margingLeft;
var margingRight;
function margLeft() {
var m = parseInt(document.getElementById('thumbs').style.marginLeft);
if (m < 5) {
m+=10; document.getElementById('thumbs').style.marginLeft=m+'px';
margingLeft = setTimeout("margLeft()",50);
}
}
function margRight() {
var m = parseInt(document.getElementById('thumbs').style.marginLeft);
if (m > -1200) {
m-=10;
document.getElementById('thumbs').style.marginLeft=m+'px';
margingRight = setTimeout("margRight()",50);
}
}
There might be a way to further optimize this code, but it's beyond be. Anyway, hope it helps someone.
gecko