Show day of Week

[Total: 0    Average: 0/5]

Show the day of the week.

Head Code:

<script language="javascript">
var runYet=false;
function runOnce()
{
  if(runYet)return;
  runYet=true;
  showMessage1(document.getElementById('message_box'));
  showMessage2(document.getElementById('second_box'));
}
function showMessage1(_obj)
{
  var _date=new Date();
  var _today=_date.getDay();
  var _message="[M#1] Today is";
  switch (_today)
  {
    case 0:
      _message+=" Sunday";
      break;
    case 1:
      _message+=" Monday";
      break;
    case 2:
      _message+=" Tuesday";
      break;
    case 3:
      _message+=" Wednesday";
      break;
    case 4:
      _message+=" Thursday";
      break;
    case 5:
      _message+=" Friday";
      break;
    case 6:
      _message+=" Saturday";
      break;
    default:
      _message="[M#1] ERROR: Date lookup function failed";
  }
  _message+=".";
  _obj.innerHTML=_message;
}
function showMessage2(_obj)
{
  var _date=new Date();
  var _today=_date.getDay();
  var _day_array=new Array();
  var _i=0;
  _day_array[_i++]="Sunday";
  _day_array[_i++]="Monday";
  _day_array[_i++]="Tuesday";
  _day_array[_i++]="Wednesday";
  _day_array[_i++]="Thursday";
  _day_array[_i++]="Friday";
  _day_array[_i++]="Saturday";
  var _message="[M#2] Today is "+_day_array[_today]+".";
  _obj.innerHTML=_message;
}
</script>

Init Code:

runOnce();

Body Code:

<div id=message_box>DEFAULT_MESSAGE</div>
<HR>
<div id=second_box>SECOND BOX</div

Times Viewed: 2

Leave a Reply

Your email address will not be published. Required fields are marked *