カレンダーポップアップ を実装したい
![](https://stat100.ameba.jp/blog/ucs/img/char/char2/039.gif)
今回は jQuery を使ってみました。
まずは、jQueryをダウンロード ( http://jqueryui.com/download )
Datepicker しか使わないので、「Core」と「Datepicker」にだけチェックを入れて、ダウンロードしましょう。
お次は、ダウンロードしたzipファイルを解凍して使うものだけをサーバーにアップ
お次は、ダウンロードしたzipファイルを解凍して使うものだけをサーバーにアップ
使用するファイルはcssの1つ
css/ui-lightness/jquery-ui-1.8.23.custom.css
と
画像フォルダの全ファイル
css/ui-lightness/images
と
下記の3つ。jsフォルダまとめて入れて残りのファイルは削除する。
jsフォルダの中の
js/jquery-1.8.0.min.js
js/jquery-ui-1.8.23.custom.min.js
development-bundle/ui/i18n/jquery.ui.datepicker-ja.js
jsフォルダ・cssフォルダ・imagesフォルダをサーバーにアップする
フォルダ構造は環境に合せよう!!
2つのテキストボックスがある場合のサンプルです。
-----------------------------------------------------------------
フォルダ構造は環境に合せよう!!
よいよ、実装だ![](https://stat100.ameba.jp/blog/ucs/img/char/char2/038.gif)
![](https://stat100.ameba.jp/blog/ucs/img/char/char2/038.gif)
赤字の部分は、パラメータです。
jQuery UIのDatepickerには多数のパラメータがあります。
詳しくは公式サイト (http://jqueryui.com/demos/datepicker/)の説明を見ようね。
2つのテキストボックスがある場合のサンプルです。
-----------------------------------------------------------------
<head>
<link type="text/css" href="jquery-ui-1.8.23.custom.css" rel="stylesheet" />
</head>
<body>
日付1:<input type="text" id="datepicker">
日付2:<input type="text" id="datepicker2">
<br>
<script src="jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<script src="jquery.ui.datepicker-ja.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
$("#datepicker2").datepicker({
firstDay: 1,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
});
});
</script>
</body>