0

Web サイト用の Javascript/HTML カレンダーを作成しました。(以下の HTML)。

<table width="690" cellpadding="0" cellspacing="0" border="2" bordercolor="#999999">
<tr class="week">
    <td width="98" class="dayofweek">Sunday</td>
    <td width="98" class="dayofweek">Monday</td>
    <td width="98" class="dayofweek">Tuesday</td>
    <td width="98" class="dayofweek">Wednesday</td>
    <td width="98" class="dayofweek">Thursday</td>
    <td width="98" class="dayofweek">Friday</td>
    <td width="98" class="dayofweek">Saturday</td>
</tr>
<tr class="week" valign="top">
    <td class="day" id="d1"><div class="daynumb" id="1"></div></td>
    <td class="day" id="d2"><div class="daynumb" id="2"></div></td>
    <td class="day" id="d3"><div class="daynumb" id="3"></div></td>
    <td class="day" id="d4"><div class="daynumb" id="4"></div></td>
    <td class="day" id="d5"><div class="daynumb" id="5"></div></td>
    <td class="day" id="d6"><div class="daynumb" id="6"></div></td>
    <td class="day" id="d7"><div class="daynumb" id="7"></div></td>
</tr>
<tr class="week" valign="top">
    <td class="day" id="d8"><div class="daynumb" id="8"></div></td>
    <td class="day" id="d9"><div class="daynumb" id="9"></div></td>
    <td class="day" id="d10"><div class="daynumb" id="10"></div></td>
    <td class="day" id="d11"><div class="daynumb" id="11"></div></td>
    <td class="day" id="d12"><div class="daynumb" id="12"></div></td>
    <td class="day" id="d13"><div class="daynumb" id="13"></div></td>
    <td class="day" id="d14"><div class="daynumb" id="14"></div></td>
</tr>
<tr class="week" valign="top">
    <td class="day" id="d15"><div class="daynumb" id="15"></div></td>
    <td class="day" id="d16"><div class="daynumb" id="16"></div></td>
    <td class="day" id="d17"><div class="daynumb" id="17"></div></td>
    <td class="day" id="d18"><div class="daynumb" id="18"></div></td>
    <td class="day" id="d19"><div class="daynumb" id="19"></div></td>
    <td class="day" id="d20"><div class="daynumb" id="20"></div></td>
    <td class="day" id="d21"><div class="daynumb" id="21"></div></td>
</tr>
<tr class="week" valign="top">
    <td class="day" id="d22"><div class="daynumb" id="22"></div></td>
    <td class="day" id="d23"><div class="daynumb" id="23"></div></td>
    <td class="day" id="d24"><div class="daynumb" id="24"></div></td>
    <td class="day" id="d25"><div class="daynumb" id="25"></div></td>
    <td class="day" id="d26"><div class="daynumb" id="26"></div></td>
    <td class="day" id="d27"><div class="daynumb" id="27"></div></td>
    <td class="day" id="d28"><div class="daynumb" id="28"></div></td>
</tr>
<tr class="week" valign="top">
    <td class="day" id="d29"><div class="daynumb" id="29"></div></td>
    <td class="day" id="d30"><div class="daynumb" id="30"></div></td>
    <td class="day" id="d31"><div class="daynumb" id="31"></div></td>
    <td class="day" id="d32"><div class="daynumb" id="32"></div></td>
    <td class="day" id="d33"><div class="daynumb" id="33"></div></td>
    <td class="day" id="d34"><div class="daynumb" id="34"></div></td>
    <td class="day" id="d35"><div class="daynumb" id="35"></div></td>
</tr>

ロード時に日付をチェックし、それに応じて月を変更する正しい関数を呼び出す JavaScript 関数を作成しました。つまり、カレンダーの日付は常に変化します。毎月の日付を変更する JS 関数を作成する必要があります。以下は私が使用しているJavaScriptです。それはまったく何もしません。私はあなた (そして私自身) に何が起こっているかを示すためにたくさんコメントしました。

function february() { //this is the function for February
var numbdays = 28; //February has 28 days

for (var date=1 /* February starts on Day 1 */;date<=numbdays /* make sure it doesn't exceed 28 days */;date++ /* advance the date number */) { 
    for (var id=6 /* Day 1 of Feb is on the id "6" */;id<=34 /* 6+28=34, don't exceed past id "34" */;id++ /* advance the id number */) {
        var idstring = id.toString(); //I have no clue if the toStrings even need to be here.
        var datestring = date.toString();
        document.getElementById(idstring).innerHTML = datestring; //change the text to the correct date for the correct id.
    }
}

} //何も起こりません...

何か案は?私は何を間違っていますか?

4

0 に答える 0