ODBiC Discussion Board


The calendar scipt file created by ODBscript - free to use

by Gordon Hsu, May 19, 2006 07:16

Roger,

I have been thinking to improve my web page by using the calendar script file to prevent user inputting the wrong date (like 2/31/2006, 2/2006 etc). I just don't have time to do it. Luckily, I saw your idea in the discussion board of how to implement the calendar file. But for me, it is not enough, because it is not the complete file for people to use immediately. Recently I have some free time so that I use your idea to create the calendar file with ODBscript. In return to your generous giving of creative idea you have, I post here for the ODBscript community to use free.

Basically, there are two files involved (you will need to put these two files in the same directory). One is Web Form (calendarform.odb) to call the another file (calendar.odb). You can further improve it by adding the image file in the calendarform.odb.

calendarform.odb:

<HTML><HEAD><TITLE>Calendar Form</TITLE></HEAD><BODY>
<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
	<!--
		var browser = navigator.appName + " " + navigator.appVersion;
		function odbCalendar(odbUrl) {
			var odbWind = window.open(odbUrl,'remote','width=200,height=200');
			if (odbWind.opener == null) {
				odbWind.opener = window;
			}
		}
	// -->
</SCRIPT>

<FORM NAME="Form1" METHOD="post"> <INPUT TYPE="text" NAME="Date1" SIZE="10" REAONLY> <A HREF="javascript:odbCalendar('calendar.odb?odbForm=Form1&odbDate=Date1&begDate=$DATE_SHORT$')">Get Calendar Date</A> </FORM>

</BODY></HTML>

calendar.odb:

<HTML><HEAD>
<!--NOTE The script is created by Roger Harris and Kuo-Tung Hsu on 05/19/2006.  Please feel free to use it -->
<!--DEFAULT begDate=$MONTH$"/"$DAY$"/"$YEAR$, odbForm="Form1", odbDate="Date1" -->
<!--SET MonthName = $FORMAT("Mmmm",$begDate$),
	YearID = $FORMAT("yyyy",$begDate$),
	MonthID = $FORMAT("mm",$begDate$),
	WeekNum1stDayOfMonth = $MOD($DATEDIFF("12/31/1899",$MonthID$"/1/"$YearID$),7),
	DayNumInMonth = $DATEDIFF($MonthID$"/1/"$YearID$,$DATEADD($MonthID$"/1/"$YearID$,1,"mm/dd/yyyy","M")),
	StartMonth = $MonthID$"/"01"/"$YearID$,
	WeekNum = 0,
	DayNum = 0
-->
<SCRIPT LANGUAGE="JavaScript">
	<!--
		function AddDate(odbDay) {
			opener.document.$odbForm$.$odbDate$.value = odbDay; 
			close();
		}
	//-->
</SCRIPT>
<TITLE>Calendar</TITLE></HEAD><BODY BGCOLOR=#FFFFFF WIDTH=90%>

<CENTER><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="1" BGCOLOR="#F0F0F0"> <TR> <TD ALIGN="CENTER"><A HREF="calendar.odb?begDate=$DATEADD($StartMonth$,-1,'mm/dd/yyyy','M')&odbForm=$odbForm$&odbDate=$odbDate$"><</A></TD> <TD COLSPAN=5 ALIGN=CENTER BGCOLOR="#F0F0F0"><B>$MonthName$ $YearID$</B></TD> <TD ALIGN="CENTER"><A HREF="calendar.odb?begDate=$DATEADD($StartMonth$,1,'mm/dd/yyyy','M')&odbForm=$odbForm$&odbDate=$odbDate$">></A></CFOUTPUT></TD> </TR> <TR BGCOLOR="#CCCCCC" ALIGN=CENTER> <TD><B>S</B></TD><TD><B>M</B></TD><TD><B>T</B></TD><TD><B>W</B></TD><TD><B>T</B></TD><TD><B>F</B></TD><TD><B>S</B></TD> </TR>

<!--WHILE $DayNum$ <= $DayNumInMonth$ --> <!--IF $WeekNum$ = 0 --> <TR BGCOLOR=#E0E0E0> <!--ENDIF --> <!--IF $DayNum$ = 0 --> <!--IF $WeekNum$ = $WeekNum1stDayOfMonth$ --> <!--SET DayNum = 1 --> <!--ELSE --> <TD WIDTH="40" VALIGN="top" ALIGN="right"> </TD> <!--ENDIF --> <!--ENDIF --> <!--IF $DayNum$ > 0 --> <TD WIDTH="40" VALIGN="top" ALIGN="right" BGCOLOR=$IF($YearID$$MonthID$$IF(LEN($DayNum$)=1,0)$DayNum$=$DATE_YMD$,"#c0c0ff")> <A HREF=javascript:AddDate('$MonthID$/$IF(LEN($DayNum$)=1,0)$DayNum$/$YearID$')>$DayNum$ </A> </TD> <!--SET DayNum = $DayNum$ + 1 --> <!--ENDIF --> <!--SET WeekNum = $WeekNum$ + 1 --> <!--IF $WeekNum$ > 6 --> </TR> <!--SET WeekNum = 0 --> <!--ENDIF --> <!--ENDWHILE --> <!--IF $WeekNum$ > 0 --> <!--WHILE $WeekNum$ < 7 --> <TD WIDTH="40" VALIGN="top" ALIGN="right"> </TD> <!--SET WeekNum = $WeekNum$ + 1 --> <!--ENDWHILE --> </TR> <!--ENDIF--> </TABLE></CENTER> <FORM> <CENTER><input TYPE="BUTTON" name="Close" VALUE="Close" onclick=window.close()></CENTER> </FORM>

</BODY></HTML>



Replies:


Post Your Reply:

Name   
E-mail  optional
Topic  
Message:

HTTP Link: 
Link text: 

          


Copyright ©1997-2003, Roger Harris. All rights reserved.