カレンダーの作り方がわかりません
-
0 名前: Lisa : 2006/03/30 00:39
- ホームページ作成は全くの初心者です。
ホームページビルダーV9 を使用しています。
カレンダーを作りたいのですが、詳しく解説しているサイト様や
作り方をご存知の方がいらっしゃいましたら、教えていただけませんか?
宜しくお願い致します!
-
1 名前: ぼうろ : 2006/03/30 00:39
- ホームページ作成は全くの初心者でカレンダーは無理でしょ。
-
2 名前: S : 2006/03/30 00:39
- メーカーの公式サポートのFAQ(よくある質問と回答)に答えがある”かも”しれない。
#探そうとおもったけど、JavaScriptがOFFだと検索ができない仕様なので検索できなかった。
パーソナル・ソフトウェア・オンラインサポート)
http://www-06.ibm.com/jp/software/esupport/
なお、ホームページビルダーでも設定方法などに注意することでそこそこよいHTML文書が作成可能。
ホームページ・ビルダーV9ではじめてのWebページ)
http://hpbuilder.net/
-
3 名前: Lisa : 2006/03/30 00:39
- >>2 Sさま、ありがとうございます^^
さっそく見てみます!
-
4 名前: Pid : 2006/03/30 00:39
- http://www.tagindex.com/cgi-lib/q4bbs/patio.cgi?mode=view&no=101

で週ごとの日付データを生成できるので,後は表などを使って整形して下さい。
-
5 名前: Lisa : 2006/03/30 00:39
- >>4 Pid さま、ありがとうございます!
参考にさせていただきます。
-
6 名前: Lisa : 2006/03/30 00:39
- 下記のように作成したのですが、年月日の文字色を変更するには
どこを書き換えたらよいのでしょうか?
<HEAD>
<SCRIPT language="JavaScript">
<!--
function calendar() {
var date = new Date();
var Monthdays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var Days = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
year = date.getYear();
today = date.getDate();
//年
if(year<2000){
year = year+1900;
}
if((year%4==0)&&(year%100!=0)||(year%400==0)){
Monthdays[1] = 29;
}
//今月
thisMonthDays = Monthdays[date.getMonth()];
//1日の取り出し
date.setDate(1);
startday = date.getDay();
//年・月日の表示
document.write("<TABLE border=0 bgcolor=#FFE8E8 cellpadding=1 cellspacing=1>");
document.write("<TR bgcolor='#ffffff'><TH colspan=7>");
document.write(year,'年',date.getMonth()+1,'月');
document.write("</TH> </TR>");
//曜日の表示
document.write("<TR bgcolor=#FFE8E8>");
for(i=0;i<7;i++){
document.write("<TH>",Days[i],"</TH>");
}
//日にちの表示
document.write("<TR bgcolor=#FFFFFF>");
//空欄
col = 0;
for(i=0;i<startday;i++){
document.write("<TD></TD>");
col++;
}
//日にち
for(i=1;i<=thisMonthDays;i++){
//今日
if(i==today){
document.write("<TD width=25 style={background-color:#B7C6EE}>");
document.write("<FONT color=#382DBA>");
document.write(i);
document.write("</FONT>");
}
else if(col==0){
document.write("<TD width=25>");
document.write("<FONT color=#EF2C3F>");
document.write(i);
document.write("</FONT>");
}
else{
document.write("<TD width=25>");
document.write(i);
}
document.write("</TD>");
col++;
if(col==7){
document.write("</TR>\n<TR bgcolor=#FFFFFF>");
col=0;
}
}
while(col!=7){
document.write("<TD width=25>");
document.write(" ");
col++;
}
document.write("</TR>");
document.write("</TABLE>");
}
//-->
</SCRIPT>
</HEAD>
<BODY><SCRIPT LANGUAGE="JavaScript">
<!--
calendar();
//-->
</SCRIPT>
</BODY>
-
7 名前: Pid : 2006/03/30 00:39
- >>6
そのスクリプトは酷すぎます。絶対に使用しないで下さい。
>>4 のコードを拝借して
var data = calendar_2D (2006, 2);
とすれば,2006 年 3 月の日付データが二次元配列として返ってきます(たとえば data[0][4] は,第 1 週の第 5 日,つまり木曜日の日付)。日付のないときは空欄になっています。あとは for/while で適当に回してタグ付けするなり,ノード付加するなりすれば良いだけです。
JavaScript を知らなくても,HTML/CSS が分かれば色変えは簡単にできると思いますので,これを機に HTML/CSS を学んでみて下さい。
-
8 名前: 匿名希望 : 2006/03/30 00:39
- すくなくとも下記の文法チェッカでプラス点になるように。
http://htmllint.itc.keio.ac.jp/htmllint/htmllint.html
-
9 名前: Lisa : 2006/03/30 00:39
- みなさん、ご親切にどうもありがとうございました!
もっと勉強して頑張ってみますm(_ _)m
-
10 名前: Pid : 2006/03/30 00:39
- >>7
> var data = calendar_2D (2006, 2);
ごめんなさい嘘つきました。これは 2 月のデータを返します。使用者が月を -1 する必要はありません(うまい作りだと思います)。以下は大してうまくないです。
function createCalendarText (node, text) {
return text ? node.appendChild (document.createTextNode (text)) : null;
}
function createCalendarTable (yyyy, m) {
var weeks = calendar_2D (yyyy, m);
var node = document.createElement ('table');
while (weeks.length) {
var days = weeks.shift ();
var row = node.insertRow (-1);
while (days.length) createCalendarText (row.insertCell (-1), days.shift ());
}
var names = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ];
var header = node.createTHead ().insertRow (-1);
while (names.length) createCalendarText (header.insertCell (-1), names.shift ());
createCalendarText (node.createCaption (), yyyy + ' 年 ' + m + '月');
node.summary = yyyy + ' 年 ' + m + '月のカレンダーです。';
return node;
}
createCalendarTable (2006, 3); で 2006 年 3 月のカレンダーを table 要素で返します(MSIE だと createElement ('table') で問題があった気がしますが気にしない (^^;))。