Results 1 to 2 of 2

Thread: setInterval??

  1. #1

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    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>

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    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>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width