• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 773
  • Last Modified:

Problem with JavaScript doScroll

On a web page, I have a textarea box, and a checkbox.  The javascript code is supposed to automatically scroll the textarea contents (which are dynamically updated by a vbscript), however I want the option to stop scrolling automatically once the checkbox is checked.  It all works just fine except when I click on the check box the IE window locks up..

<SCRIPT>
var iTimer;
function timeIt()
{
      iTimer = setInterval("scrollIt()", 10);
}

function scrollIt(){
do{
      document.form.wstatus.doScroll("down");
}while (document.form.wdone.checked == false)
}

</SCRIPT>
0
jb6884
Asked:
jb6884
  • 3
  • 2
1 Solution
 
k-doCommented:
The problem with your function is that it is in a perpetual loop.

iTimer = setInterval("scrollIt()", 10);

The above line sets up a timer which executes the *function* scrollIt() every 10 ms.  Since you have used a do...while statement in your function, the function continues to loop without any delay.

You need to change your scrollIt() function to the following:

function scrollIt(){
if (document.form1.wdone.checked == false)
     document.form1.wstatus.doScroll("down");
}

Hope this helps,

Keith

0
 
k-doCommented:
Check that... I modified the code when I was testing the solution... the correct code (based on what you posted) will be:

function scrollIt(){
if (document.form.wdone.checked == false)
     document.form.wstatus.doScroll("down");
}
0
 
xakemCommented:
what do you think about the following:

<html>
<head>
<script>
function stopScrl()
{
      c = document.getElementById('chkbx').checked
      s = document.getElementById('scrl')
      
      if (c)
            s.stop()
      else
            s.start()
}
</script>
</head>
<body>
<marquee id="scrl" scrollAmount="1" direction="down" style="border: solid black 2px; width: 200px"><center>scroll scroll scroll</center></marquee><input id="chkbx" type="checkbox" onClick="stopScrl()">Click
</body>
</html>

 ? this is one of the ways
0
 
k-doCommented:
xakem -

I don't think that your solution addresses the question... jb6884 specifically stated that his web page uses a textarea box and a check box.  Your solution uses a marquee.

It provides an alternative method of accomplishing the task, but there could be other reasons that jb6884 needs to specifically use a textarea box.

Keith
0
 
xakemCommented:
no problem Keith, we r free to suggest here, aren't we ;)
i will be more accurate next time, thx for reminding.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now