Skip to content

Instantly share code, notes, and snippets.

@l34marr
Created August 9, 2018 14:55
Show Gist options
  • Save l34marr/db61c56483f53d228a3c69ddc64fb2a9 to your computer and use it in GitHub Desktop.
Save l34marr/db61c56483f53d228a3c69ddc64fb2a9 to your computer and use it in GitHub Desktop.
var NOW = new Date();
var TY = NOW.getFullYear();
var TM = NOW.getMonth()+1;
function chg_cals(Y,M){
var tb=document.getElementById("cal");
var F=true;
var R=0;
var D=1;
var DW;
var DM = new Array(Y,31,28,31,30,31,30,31,31,30,31,30,31);
if( (Y%4) == 0 ){
DM[2]=29;
}
var T=tb.rows.length-1;
for(var ST=T;ST>=1;ST--){
tb.deleteRow(ST);
}
while(F){
for(var W=0;W<=6;W++){
DW = new Date(Y,Number(M)-1,D);
if(W==0 && D<=DM[Number(M)]){
R++;
var ROW = tb.insertRow(R);
}
var CE = ROW.insertCell(W);
CE.align="center";
if(DW.getDay()==W && D<=DM[Number(M)]){
CE.innerHTML="<a onclick='alert(\"Hi\")' onmouseover='style.cursor=\"pointer\"' bgcolor='#F0F'>" + D;
D++;
}
if(D>DM[Number(M)]){
F=false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment