電子書籍の厳選無料作品が豊富!

こんにちは、javascript初心者です。JScalendarについて質問です。
今JScalendar var1.00 を用いてボタンを押したらポップアップカレンダーを表示するページを作っています。

要件として、アクセス日より1年半前のカレンダーの日付は指定できないようにしたいと思っていますが、<script>タグのcalendar.setup関数でどの様にパラメータを設定してよいのか解らずこまっています。
下ページの右側flatバージョンのサンプルを見るとクリックできない日付や月を設定できているのですが、どう設定すれば良いのか、調べ方も解らず右往左往しています。

http://www.dynarch.com/static/jscalendar-1.0/ind …

使用しているカレンダーはvar1.00を使用しています。

新しいバージョンだとmin maxというパラメータを使用して日付指定すればよいとサンプルに在るのですが、var1.00を必ず使うことが必須なので、何とか解決しなければなりません。

どの様な情報でも良いので、教えていただきたいと思います。

よろしくお願いいたします。

A 回答 (2件)

<!-- main calendar program -->


<script type="text/javascript" src="calendar.js"></script>

<!-- language for the calendar -->
<!-- 日本語も用意されてるけど動かない -->
<script type="text/javascript" src="calendar-en.js"></script>

<!-- the following script defines the Calendar.setup helper function, which makes
adding a calendar a matter of 1 or 2 lines of code. -->
<script type="text/javascript" src="calendar-setup.js"></script>


<!-- setup例 -->
<!-- 入力先要素とトリガー要素 -->
<input type="text" id="field"><button id="trigger">...</button>

<script type="text/javascript">
(function() {
var d = new Date();
var y = d.getFullYear();
var old = d.getTime() - (86400000 * 500); // 500日前の時間値
Calendar.setup({
inputField : "field", // id of the input field
ifFormat : "%Y/%m/%d", // format of the input field
showsTime : false, // will display a time selector
button : "trigger", // trigger for the calendar (button ID)
singleClick : false, // double-click mode
range: [ y - 2, y + 2 ], // 前後2年を上限
// 500日以前を無効
disableFunc: function (date, year, month, iday) { if (date.getTime() <= old) return true; }
// 日曜日を無効
//disableFunc: function (date, year, month, iday) { if (date.getDay() === 0) return true; }
// 3の付く日を無効
//disableFunc: function (date, year, month, iday) { if (iday % 10 === 3 || iday >= 30) return true; }
});
})();
</script>


Calendar.setupからも関数オブジェクトを渡せるようですね。
disableFuncの値に真値を返す関数オブジェクトを設定。
この関数はその月の日数分呼出されます。
受け取れる引数は順に、Dateオブジェクト、年、月(-1)、日。

The Ex-“Coolest” DHTML Calendar :: Dynarch.com
http://www.dynarch.com/projects/calendar/old
ファイルはここから

DHTML Calendar Widget
http://www.dynarch.com/static/jscalendar-1.0/doc …
Calendar.setup オプションプロパティ解説(英語)
    • good
    • 0

これじゃないでしょうか?



http://www.dynarch.com/static/jscalendar-1.0/doc …

function disallowDate(date) {
  // date is a JS Date object
  if ( date.getFullYear() == 2003 &&
  date.getMonth() == 6 /* July, it's zero-based */ &&
  date.getDate() == 5 ) {
  return true; // disable July 5 2003
  }
  return false; // enable other dates
};

calendar.setDisabledHandler(disallowDate);

ifの条件をお望みの範囲に変更すればよいんじゃない。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!