If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Setting Boundaries for the Animate Function

Hello,

I am a complete novice to JS, and I am trying to do what I thought would be a simple task. I have a table that I would like to scroll horizontally with a 'previous' and 'next' button. I used the animate function to move the table left and right. The buttons are PNGs that link to a function like this:

The problem is if the table is at the beginning or end, clicking previous or next moves it completely out of view, so I need some way to disable the previous button at the left-most portion and disable the next button at the right-most.

I tried setting a conditional statement based on the margin left value of the object. For example, the previous button:

But I couldn't get this to work. I also thought that using some sort of counter variable and a conditional statement might work, but I have no idea how to set up the variables to do that in JS. For example, setting a variable to 0 and adding 1 every time the next button is clicked and using a conditional statement to constrain the movement to a certain number of clicks in either direction.