[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problem with JavaScript doScroll

Posted on 2004-10-22
5
Medium Priority
?
756 Views
Last Modified: 2012-06-22
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
Comment
Question by:jb6884
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:k-do
ID: 12382438
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
 
LVL 3

Accepted Solution

by:
k-do earned 200 total points
ID: 12382442
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
 
LVL 3

Expert Comment

by:xakem
ID: 12382816
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
 
LVL 3

Expert Comment

by:k-do
ID: 12382868
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
 
LVL 3

Expert Comment

by:xakem
ID: 12395191
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The viewer will learn how to count occurrences of each item in an array.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question