-
setInterval??
whats wrong with the following script..it is supposed to move 50px in every 2 seconds but there is an error!!
please tell me more on "setInterval"..thanks
<html>
<head>
<script>
a=setInterval('Moveit()',2000);
function moveit()
{
text1.style.posLeft=text1.style.posLeft+50;
}
</script>
</head>
<body onload="moveit()">
<input type=text style="position:absolute" name=text1 id=text1>
</body>
</html>
-
Javascript's case sensitive ;) :
a=setInterval('Moveit()',2000);
Although - this would be slightly better:
Code:
<html>
<head>
<script language="javascript" type="text/javascript">
a = setInterval('moveit()',2000);
function moveit()
{
var target = document.getElementById("text1");
if (target != null) {
target.style.posLeft += 50;
}
}
</script>
</head>
<body>
<input type="text" style="position: absolute;" name="text1" id="text1">
</body>
</html>