星期日, 3月 18, 2007

JSCalendar的使用

下載位置:
http://sourceforge.net/project/showfiles.php?group_id=75569

示範位置:
http://www.dynarch.com/demos/jscalendar/

加入網頁的方法:

1.下載後將檔案解壓縮至網頁根目錄的 "jscalendar" 資料夾 (可自訂名稱)

2.在檔案的<head>...</head>區域之內加入以下4行:
<style type="text/css">@import url(jscalendar/calendar-blue.css);</style>
<script type="text/javascript" src="jscalendar/calendar.js"></script>
<script type="text/javascript" src="jscalendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
(其中 jscalendar 與步驟1.設定的資料夾名稱必須相同)

3.假設在原始的表單之中,有下列原始碼:
<form ...>
<input type="text" id="Birthday" name="data" />
<button id="trigger">...</button>
</form>
其中按下 button 可出現日期選單,Birthday 是存放選取結果的欄位,

在表單之後加入以下語法即可:
<script type="text/javascript">
Calendar.setup(
{ inputField : "Birthday", // ID of the input field
ifFormat : "%Y-%m-%d", // the date format
button : "trigger" // ID of the button
}
);
</script>

沒有留言: