Javascript implemented Calendar

CK CK 3788 
Created at  
422 0 0
Nice calendar for Web page display. Highlights the date and the day of
the week. Well-documented code to help you customize any font,color,or
size you want.

<!-- TWO STEPS TO INSTALL THIS SCRIPT -->

<!-- STEP ONE: Place the following script into a separate JavaScript file called: calendar.js     -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
//  SET ARRAYS
var day_of_week = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
var month_of_year = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

//  DECLARE AND INITIALIZE VARIABLES
var Calendar = new Date();

var year = Calendar.getYear();        // Returns year
var month = Calendar.getMonth();    // Returns month (0-11)
var today = Calendar.getDate();    // Returns day (1-31)
var weekday = Calendar.getDay();    // Returns day (1-31)

var DAYS_OF_WEEK = 7;    // "constant" for number of days in a week
var DAYS_OF_MONTH = 31;    // "constant" for number of days in a month
var cal;    // Used for printing

Calendar.setDate(1);    // Start the calendar day at '1'
Calendar.setMonth(month);    // Start the calendar month at now


/* VARIABLES FOR FORMATTING
NOTE: You can format the 'BORDER','BGCOLOR','CELLPADDING','BORDERCOLOR'
      tags to customize your caledanr's look. */

var TR_start = '<TR>';
var TR_end = '</TR>';
var highlight_start = '<TD WIDTH="30"><TABLE CELLSPACING=0 BORDER=1 BGCOLOR=DEDEFF BORDERCOLOR=CCCCCC><TR><TD WIDTH=20><B><CENTER>';
var highlight_end   = '</CENTER></TD></TR></TABLE></B>';
var TD_start = '<TD WIDTH="30"><CENTER>';
var TD_end = '</CENTER></TD>';

/* BEGIN CODE FOR CALENDAR
NOTE: You can format the 'BORDER','BGCOLOR','CELLPADDING','BORDERCOLOR'
tags to customize your calendar's look.*/

cal =  '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR=BBBBBB><TR><TD>';
cal  = '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2>'   TR_start;
cal  = '<TD COLSPAN="'   DAYS_OF_WEEK   '" BGCOLOR="#EFEFEF"><CENTER><B>';
cal  = month_of_year[month]    '   '   year   '</B>'   TD_end   TR_end;
cal  = TR_start;

//   DO NOT EDIT BELOW THIS POINT  //

// LOOPS FOR EACH DAY OF WEEK
for(index=0; index < DAYS_OF_WEEK; index  )
{

// BOLD TODAY'S DAY OF WEEK
if(weekday == index)
cal  = TD_start   '<B>'   day_of_week[index]   '</B>'   TD_end;

// PRINTS DAY
else
cal  = TD_start   day_of_week[index]   TD_end;
}

cal  = TD_end   TR_end;
cal  = TR_start;

// FILL IN BLANK GAPS UNTIL TODAY'S DAY
for(index=0; index < Calendar.getDay(); index  )
cal  = TD_start   '  '   TD_end;

// LOOPS FOR EACH DAY IN CALENDAR
for(index=0; index < DAYS_OF_MONTH; index  )
{
if( Calendar.getDate() > index )
{
  // RETURNS THE NEXT DAY TO PRINT
  week_day =Calendar.getDay();

  // START NEW ROW FOR FIRST DAY OF WEEK
  if(week_day == 0)
  cal  = TR_start;

  if(week_day != DAYS_OF_WEEK)
  {

  // SET VARIABLE INSIDE LOOP FOR INCREMENTING PURPOSES
  var day  = Calendar.getDate();

  // HIGHLIGHT TODAY'S DATE
  if( today==Calendar.getDate() )
  cal  = highlight_start   day   highlight_end   TD_end;

  // PRINTS DAY
  else
  cal  = TD_start   day   TD_end;
  }

  // END ROW FOR LAST DAY OF WEEK
  if(week_day == DAYS_OF_WEEK)
  cal  = TR_end;
  }

  // INCREMENTS UNTIL END OF THE MONTH
  Calendar.setDate(Calendar.getDate() 1);

}// end for loop

cal  = '</TD></TR></TABLE></TABLE>';

//  PRINT CALENDAR
document.write(cal);

//  End -->



<!--  STEP TWO: Place this into the BODY of the HTML document where you want the calendar  -->
<!--  Make sure the '.js' and '.html' files are in the same directory.  -->

<BODY>

<SCRIPT SRC="calendar.js"></SCRIPT>


<p><center>
<font face="arial,helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  4.15 KB -->

Tags Alarm DateTime HTML Javascript javascript calendar Facebook X
Comments 0
Similar posts
  1. Basic Date Display
    511
  2. Javascript based Alarm Clock
    666
  3. How to get date time in Javascript ?
    498
  4. Hiding HTML on the browser
    461
  5. Getting WebSearchers On Your Site
    373
  6. Javascript Mouse Event Handler Example
    403
  7. Select And Deselect All Checkboxes By Javascript
    632
  8. Address Book
    576
  9. Displays the number of pages that the users browser has displayed in its session
    667
  10. Greeting For The Time Of Day
    393
  11. Access Granted
    586
  12. Cookie enabled browser checking in Javascript
    342
  13. Cookie Redirect
    496
  14. New content notifier in Javascript
    597
  15. Let popup once for event dialog or something like that in Javascript
    425
  16. Save And Restore Form Cookies in Javascript
    335
  17. How to record visitor's name by Cookie
    411
  18. Javascript & Cookie based Visitor Application
    435
  19. Cross Browser Event Management Functions Using JavaScript
    611
  20. Confirm The Link Clicked
    631
  21. Enlarge Image
    514
  22. Dual Scroller
    332
  23. Cursor Changer
    383
  24. Color Table
    365
  25. Printing A Page
    379
  26. Example Of Creating Objects
    403
  27. Linking Drop Downs
    576
  28. Roman Numerals From Integers
    511
  29. Get A Print Dialog Box By Clicking A Button
    818
  30. Keyboard event detection (Key Tracker)
    1,087
  1. New Window
    604
  2. Firefox Web Tweaking
    376
  3. Color Table
    365
  4. Cursor Changer
    383
  5. Dual Scroller
    332
  6. Enlarge Image
    514
  7. Confirm The Link Clicked
    631
  8. Send An Email Using A Bean
    1,015
  9. Select And Deselect All Checkboxes By Javascript
    632
  10. Javascript Mouse Event Handler Example
    403
  11. Getting WebSearchers On Your Site
    373
  12. Hiding HTML on the browser
    461
  13. jQuery and Function Chaining
    536
  14. How to get date time in Javascript ?
    498
  15. Javascript based Alarm Clock
    666
  16. Basic Date Display
    511
  17. Address Book
    576
  18. Displays the number of pages that the users browser has displayed in its session
    667
  19. Greeting For The Time Of Day
    393
  20. Access Granted
    586
  21. Cookie enabled browser checking in Javascript
    342
  22. Cookie Redirect
    496
  23. New content notifier in Javascript
    597
  24. Let popup once for event dialog or something like that in Javascript
    425
  25. Save And Restore Form Cookies in Javascript
    335
  26. How to record visitor's name by Cookie
    411
  27. Javascript & Cookie based Visitor Application
    435
  28. Cross Browser Event Management Functions Using JavaScript
    611
  29. Printing A Page
    379
  30. Example Of Creating Objects
    403
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    40
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    34
  3. How do I create animated background for Google Meet?
    20,613
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    245
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    514
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    287
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    230
  16. TPU & GPU Cluster Management Tools
    244
  17. The Concept of Scaffolding in AI Agents
    233
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    259
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    221
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    220
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    195
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    217
  30. Understanding Data Lineage
    260