Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q573 How can I provide links to a cgi script for the date of the next seven days?

You are here: irt.org | FAQ | JavaScript | Link | Q573 [ previous next ]

Try something like this:

<script language="JavaScript"><!--
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
function padout(number) { return (number < 10) ? '0' + number : number; }
function output_date(when) {
    var formatted_date = padout(when.getDate()) + '/' + padout(when.getMonth()+1) + '/' + y2k(when.getYear());
    document.write('<a href="http://www.somewhere.com/cgi-bin/program-name?date=' + escape(formatted_date) + '">' + formatted_date + '</a><br>');
    var next = new Date(y2k(when.getYear()),when.getMonth(),when.getDate()+1)
    return next;
}

var now   = new Date();

for (var i=0; i<7; i++)
    now = output_date(now);
//--></script>

©2018 Martin Webb