Click to See Complete Forum and Search --> : moving text


shad1027
04-20-2003, 06:50 AM
I am trying to put a box on my page with moving text but I can't seem to find the code I used to use...If anyone knows where I could find one or has it handy...I would very much appreciate it...

shad1027
04-20-2003, 07:10 AM
I am trying to put a box on my page with moving text but I can't seem to find the code I used to use...If anyone knows where I could find one or has it handy...I would very much appreciate it...

khalidali63
04-20-2003, 07:25 AM
First of all you did not have to start 2 threads for one topic,

in the body section of the page put this line

<div id="movingtext" style="position:absolute;font-weight:bold;left:0px;top:10px;z-index:999;">This is moving text</div>

<form name="form1" action="" onsubmit="">
<div align="center">
<input type="Button" name="btn" value="Start Moving" onclick="startAnim();"/>
</div>
</form>


between the <head></head>
tags put the following code


<script type="text/javascript">
var speed =4;//lesser the number faster will be the speed
var movingTimer;
function startAnim(){
if(document.form1.btn.value=="Start Moving"){
document.form1.btn.value="Stop Moving"
moveIt();
}else if(document.form1.btn.value=="Stop Moving"){
document.form1.btn.value="Start Moving"
clearTimeout(movingTimer);
}
}

function moveIt(){
var obj = document.getElementById("movingtext");
if(parseInt(obj.style.left)==600){
obj.style.left = 10+"px";
}else{
var objX = parseInt(obj.style.left);
obj.style.left = (objX + 5)+"px";
}
movingTimer = setTimeout('moveIt()',speed*10);
}
</script>


hope this helps
:D