Hi
This code must start text moving a number of times according to the value entered in the <input>. The text can only start when 'ronmouseove' event is done over the text, not when the button is clicked. This is what now happens: the text starts moving after clicking on the button by this line: document.getElementById("clem").onmouseover = start(a); But I may as well write something like document.getElementById("clem").xxx = start(a); it also starts.
Any hints? Thanks. V
<html>
<body>
<div ID="cc" STYLE="position:fixed;top:50px">Moving text!</div>
Number of times:
<input id="Text1" type="text" style="width:30px" autofocus />
<input id="Button1" type="button" value="start" onclick="num()" />
<script type="text/javascript">
var go = document.getElementById("cc");
var x = 0;
var y = 0;
function num() {
var a = document.getElementById("Text1").value;
go.onmouseover = start(a);
}
function start(z) {
y += 1;
if (y < z * 500)
{
if (x < 500) {
x += 1;
go.style.left = x + "px";
if (x == 500)
{
x = 0;
}
setTimeout(start, 10, z);
}
}
}
</script>
</body>