Devlin Technical Consulting Home
2522 N. Proctor Street #428, Tacoma, WA 98406
PH: (253)272-5743 email: jdevlin@stadiumdistrict.com

Create HTML Date and Time pop up menus from your Perl CGI scripts

Previous Next
Examples:

Historical Dates
Look back in time to find records that reference something that
has already happened.

First, decide how far back the user will probably want to search.
Then, choose a default.  If the user will be deleting or archiving
records based on the date it may be wise to choose a time far enough
back that recent records will not be deleted.  If the user is just
looking for stuff before a certain date, but they don't know exactly
what they are looking for, then choosing today's date would work.

Here is a code snippet that defaults to a year ago.

	# - - - - - -
	# get the current year
	my $timeoffset=0;
	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
	   = localtime(time + (3600*$timeoffset));
	$year = $year + 1900;
	

	#create the drop downs for date and time
	# choose a year ago this month so the user will not
	# accidentally delete this years data entry.
	$fields{grad_year} = date_time_pop('YEAR',$year-1,'grad_year',5,5);
	$fields{grad_month} = date_time_pop('MONTH',$mon+1,'grad_month');

	#display the archive when form to allow the user to choose an archive date
	    my $filetoopen="/the_place_for/my_archive/when.html";
	    print "Content-type: text/html\n\n"; # must preceed print template command
	    # template is a custom subroutine, one could also use the template 
	    # module from CPAN
	    print template( "$document_root" . "$filetoopen", \%fields);




Synopsis:
date_time_pop('DATE_TIME_TYPE, SELECTED_DEFAULT, NEGATIVE_OFFSET, POSITIVE_OFFSET')


The required arguments to Datimenu are the DATE_TIME_TYPE, SELECTED_
DEFAULT, NEGATIVE_OFFSET, POSITIVE_OFFSET.

The result is a pop up HTML tag that is returned as a scalar, for you to embed
in you web page.  The pop up tag could be embedded either by using a template
module or by server side includes.



The simulated result of the HTML tags returned:
Archive before:

 
     
   







Page Modified 11/25/02