Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaoru-fukusato/e257972b1f4b4a5d9633ae694e8df233 to your computer and use it in GitHub Desktop.
Save kaoru-fukusato/e257972b1f4b4a5d9633ae694e8df233 to your computer and use it in GitHub Desktop.
コピペで学べるプログラミング基本2-7
<script type="text/javascript"><!--
myTbl = new Array( // 行事テーブル(月,日,メッセージ)
1, 1,"元旦",
1,14,"成人の日",
2,11,"建国記念の日",
4,29,"みどりの日",
5, 3,"憲法記念日",
5, 4,"国民の日",
7,20,"海の日",
9,15,"敬老の日",
10,14,"体育の日",
11, 3,"文化の日",
11,23,"勤労感謝の日",
12,23,"天皇誕生日"
);
function myWrite(){
myMess = ""; // メッセージ表示用
myTblCnt = myTbl.length / 3; // テーブルの数を取得/計算
myD = new Date(); // 現在の日付取得
myMonth = myD.getMonth()+1; // '月'取得
myDate = myD.getDate(); // '日'取得
for(i=0; i<myTblCnt; i++){ // テーブルの数だけループ
if (myTbl[i*3] == myMonth && myTbl[i*3+1] == myDate){ // '月' と '日'が一致したら..
myMess += "● " + myTbl[i*3+2] + "<BR>"; // 行事メッセージ追加
}
}
if ( myMess != "" ) document.getElementById( "info" ).innerHTML = myMess;
}
// --></script>
<DIV id="info">● 本日の行事は何もありません。</DIV>
<script type="text/javascript"><!--
myWrite();
// --></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment