<SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Author: www.cgiscript.net --> <!-- Begin // Get today's current date. var now = new Date(); // Array list of days. var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); // Array list of months. var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December'); // Calculate the number of the current day in the week. var date = ((now.getDate()<10) ? "0" : "")+ now.getDate(); // Calculate four digit year. function fourdigits(number) { return (number < 1000) ? number + 1900 : number; } // Join it all together today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())) ; // Print out the data. document.write(today); // End --> </script>
<script>// Version 1.0 // Written by : Anthony Alsford - EDATA Limited // Purpose : To populate all calendar controls on a form with an elementtype attribute // set to "editcalendar". // This function is called on form loading and pulls a collection of calendar controls // before calling the function to set the date value function PrepDates() { for (i=0;i<document.all.length;i++) { if (document.all(i).elementtype == "editcalendar") { this.displayElement = document.getElementById (document.all(i).id); SetDate(document.all(i).id); } } } // This function is designed to set the date value according to an offset value contained // within the input tag. // The only parameter required is the elements id value. function SetDate(item) { this.displayElement = document.getElementById(item); var today = new Date(); var offset = this.displayElement.getAttribute('dateoffset'); //alert(offset); today.setDate(today.getDate()-offset); var t_date = today.getDate(); if (t_date<10) {t_date='0'+t_date}; var t_mnth = today.getMonth()+1; if (t_mnth<10) {t_mnth='0'+t_mnth}; var t_year = today.getFullYear(); t_year = t_year - 2000 ; if (t_year<10) {t_year='0'+t_year}; var end_date = t_date+"/"+t_mnth+"/"+t_year; this.displayElement.value = end_date; } </script>
<script src=filename.js></script>or just include it within you HTML. Generally it does matter where you put the code, but as you would be calling this from your onload event you can place it inbetween the close body and close html tags.
PrepDates();Remember that JS is case sensitive.
In FOCUS since 1986 | WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2 | ||
WebFOCUS App Studio 8.2.06 standalone on Windows 10 |