A
AC
Hello,
I am completely new to javascript and am trying to create a function
that will move a textbox 250px to the left and 250px to the right,
using a for loop. I can't figure out how to add the i value to the top
and left values.
Below is the code. Can somebody please help?
Thanks in advance.
Regards,
A. Crawford
<html>
<head>
<script type="text/javascript">
<!--
function moveit() {
for(i=0;i<=50;i=i+10){
counter.cffield.style.top += i + 'px';
counter.cffield.style.left += i + 'px';
}
}
//-->
</script>
</head>
<body>
<form name="counter">
<input type="button" value="Move" onclick="moveit()">
<input type="text" name="cffield" value="" size="25"
style="position:absolute;top:0px;left:65px">
</form>
</body>
</html>
I am completely new to javascript and am trying to create a function
that will move a textbox 250px to the left and 250px to the right,
using a for loop. I can't figure out how to add the i value to the top
and left values.
Below is the code. Can somebody please help?
Thanks in advance.
Regards,
A. Crawford
<html>
<head>
<script type="text/javascript">
<!--
function moveit() {
for(i=0;i<=50;i=i+10){
counter.cffield.style.top += i + 'px';
counter.cffield.style.left += i + 'px';
}
}
//-->
</script>
</head>
<body>
<form name="counter">
<input type="button" value="Move" onclick="moveit()">
<input type="text" name="cffield" value="" size="25"
style="position:absolute;top:0px;left:65px">
</form>
</body>
</html>