Link to home
Start Free TrialLog in
Avatar of Gareth Pritchard
Gareth PritchardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

define an integer variable appended with px

basically the script below modifies some CSS to scroll down a div menu, the problem is it doesnt seem to scroll down in pixels ( if i change for example "(<37)" to "(<36)" the layer actually repositions by roughly 10pixels.

var i=-150;
var intHide;

function show()
{
if (i<37)
      {
      i=i+4;
      document.all("foo").style.top=i-1;
      }
}

function showmenu()
{
clearInterval(intHide);
intShow=setInterval("show()",1);
}

function hide()
{
if (i>-150)
      {
      i=i-4;
      document.all("foo").style.top=i;
      }
}

function hidemenu()
{
clearInterval(intShow);
intHide=setInterval("hide()",1);
}
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gareth Pritchard

ASKER

nice, thanks for the tip-off :)

if (i<39)
      {
      i=i+4;
      document.all("foo").style.top=i-3;
                }

you have earned the points:

just to clarify, where did you get 9*4=36 based on the script ?
i see the *4 is from i+i=4;
i understand the mathematics behind the problem ( thanks to your explanation ),
i just dont see where the 9* comes into it.

Sorry, the guess with nine was wrong. You start from minus 150 and go to 36 or 37. Therefore you have either 46 or 47 steps each 4 pixels.