localendar Forums Homepage


Print at Nov 7, 2025, 8:35:20 AM

Posted by support at Jan 13, 2013, 5:35:57 PM
Re: Show next month
I don't like the look of "Month+1, Month+2, etc"
I mean, if you really want to be "responsive", we should show the proper month names for the period. So here's the "extra-credit" version that handles that:

<a href='http://www.localendar.com/public/n1lykme'>This Month</a><br/>
<script>

var month_names = new Array ( );
month_names[month_names.length] = "January";
month_names[month_names.length] = "February";
month_names[month_names.length] = "March";
month_names[month_names.length] = "April";
month_names[month_names.length] = "May";
month_names[month_names.length] = "June";
month_names[month_names.length] = "July";
month_names[month_names.length] = "August";
month_names[month_names.length] = "September";
month_names[month_names.length] = "October";
month_names[month_names.length] = "November";
month_names[month_names.length] = "December";

function getNextCalendarMonth(in_date)
{
if (in_date.getMonth() == 11) {
var out_date = new Date(in_date.getFullYear() + 1, 0, 1);
} else {
var out_date= new Date(in_date.getFullYear(), in_date.getMonth() + 1, 1);
}
return out_date;
}
function formatDate(in_date)
{
var out_string = "";
out_string = (in_date.getMonth()+1)+"/"+in_date.getDate()+"/"+in_date.getFullYear();
return out_string;
}

var mplus1=getNextCalendarMonth(new Date());
var mplus2=getNextCalendarMonth(mplus1);
var mplus3=getNextCalendarMonth(mplus2);
var mplus4=getNextCalendarMonth(mplus3);
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus1)+"'>"+month_names[mplus1.getMonth()]+"</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus2)+"'>"+month_names[mplus2.getMonth()]+"</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus3)+"'>"+month_names[mplus3.getMonth()]+"</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus4)+"'>"+month_names[mplus4.getMonth()]+"</a><br/>");
</script>


This seemed FAQ-worthy: http://www.localendar.com/docs/display/lc/Dynamic+links+to+multiple+calendar+months
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news

Help! | Cobranding | Legal | Privacy Policy | About localendar.com | Contact Us