Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clearInterval is erasing the text, please help...?

Status
Not open for further replies.

SoLoGHoST

Programmer
Jul 23, 2008
2
US
I am having this problem when running the code contained in the following javascript function...

Didn't include the DateTimePrep function, however, I know it works because I tested it without the ClearInterval(Timer); code at the beginning of this function and it shows the text using innerHTML just fine. However, once I click a button to change the text and the function startText() is called yet again it doesn't clear the interval, so I decided I need the ClearInterval(Timer); statement. But when testing this function, it simply shows NO TEXT at all...??? It seems to be wiping out the interval altogether as if it never existed. Can anyone please help me?? Why is the ClearInterval(Timer); code in the beginning of this function making it so that it won't let me setInterval???

function startText(xType)
{

ClearInterval(Timer);

if (xType == "TimeDefault")
{
DateTimePrep('TimeDefault');
Timer = setInterval('DateTimePrep(\'TimeDefault\')', 1000);
}
if (xType == "TimeNoSec")
{
DateTimePrep('TimeNoSec');
Timer = setInterval('DateTimePrep(\'TimeNoSec\')', 1000);
}
if (xType == "TimeMilitary")
{
DateTimePrep('TimeMilitary');
Timer = setInterval('DateTimePrep(\'TimeMilitary\')', 1000);
}
if (xType == "TimeDate")
{
DateTimePrep('TimeDate');
Timer = setInterval('DateTimePrep(\'TimeDate\')', 1000);
}

if (xType == "DayWeek")
{
DateTimePrep('DayWeek');
Timer = setInterval('DateTimePrep(\'DayWeek\')', 1000);
}

if (xType == "CPURes")
{
SysResourcePrep('CPURes');
Timer = setInterval('SysResourcePrep(\'CPURes\')', 500);
}
if (xType == "MemRes")
{
SysResourcePrep('MemRes');
Timer = setInterval('SysResourcePrep(\'MemRes\')', 500);
}

}
 
Okay, I'm an idiot...lol.

I had clearInterval(Timer); with the C capitalized. Just switched it to lowercase and all works fine.

This case sensitive stuff really gets me sometimes...lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top