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>
jb6884Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xakemSoftware Application DeveloperCommented:
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
xakemSoftware Application DeveloperCommented:
no problem Keith, we r free to suggest here, aren't we ;)
i will be more accurate next time, thx for reminding.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.