[Javascript] Newbie- Error Message??

Steve extstarrfam at cox-internet.com
Mon Mar 18 01:02:37 CST 2002


At the line 'var secCtr = theDate.Seconds();', I get the error message "Object does not support this property or method".  The code that contains it is used to flash a message in a TextBox.  When I replace the secCtr variable with theDate.Seconds() and use it in If statements, it works.  Some one please explain to me in simple terms why I'm getting the error message.  Here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html><title>Text Flash XP</title>
<head>
<script language="JavaScript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com
// Altered by S. Starr 11/18/02.
var pace = 0;

function UpdateClock() {
 if(pace) {
  clearTimeout(pace);
  pace  = 0;
 }

 var theDate = new Date();
 var secCtr = theDate.Seconds();
 
 switch(secCtr)
 {
     case secCtr <= 2:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 2 && secCtr <= 5:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 5 && secCtr <= 7:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 7 && secCtr <= 10:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 10 && secCtr <= 12:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 12 && secCtr <= 15:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 15 && secCtr <= 17:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 17 && secCtr <= 20:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 20 && secCtr <= 22:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 22 && secCtr <= 25:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 25 && secCtr <= 27:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 27 && secCtr <= 30:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 30 && secCtr <= 33:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 33 && secCtr <= 35:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 35 && secCtr <= 38:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 38 && secCtr <= 40:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 40 && secCtr <= 43:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 43 && secCtr <= 45:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 45 && secCtr <= 48:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 48 && secCtr <= 50:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 50 && secCtr <= 53:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 53 && secCtr <= 55:
  document.theForm.textDisplay.value="";
  break;
     case secCtr > 55 && secCtr <= 57:
  document.theForm.textDisplay.value = "READ THIS NOW";
  break;
     case secCtr > 57 && secCtr <= 59:
  document.theForm.textDisplay.value="";
  break;
     default:
  document.theForm.textDisplay.value="no display";
 }

 pace = setTimeout("UpdateClock()", 1000);
}

function startFlash() {
 pace = setTimeout("UpdateClock()", 500);
}

function stopFlash() {
 if(pace) {
  clearTimeout(pace);
  pace  = 0;
 }
}

//-->
</script>
</head>
<body onload="startFlash()" onunload="stopFlash()">
<form name="theForm">
<input type="text" name="textDisplay" length="12" style="font-size: x-large; text-align: center; background: #0000FF; color: #FFFFFF;">
</form>
</body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20020318/ed51ca9d/attachment.htm>


More information about the Javascript mailing list