เริ่มต้น jQuery UI กับการสร้าง ปฏิทินเลือกวันที่ datepicker
16 August 2009ตัวอย่างผลลัพธิ์
ดาวน์โหลด jQuery UI ได้ที่เว็บไซต์ http://jqueryui.com/หรือดาวน์โหลดได้ที่ คลิกที่นี่
แตกไฟล์ jquery-ui-1.7.2.custom.zip โฟลเดอร์ที่นำไปใช้มี โฟลเดอร์ css และ js
การเรียกใช้งาน jQuery UI
<link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui-1.7.2.custom.css">
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
$(function(){
// แทรกโค้ต jquery
$("#dateInput").datepicker();
});
</script>
CSS code กำหนดความกว้าง และขนาดตัวอักษรของ ปฏิทิน
<style type="text/css">
.ui-datepicker{
width:150px;
font-family:tahoma;
font-size:11px;
text-align:center;
}
</style>
HTML code text box สำหรับเลือกวันที่จากปฏิทิน
<input type="text" name="dateInput" id="dateInput" />
เราสามารถกำหนดรูปแบบวันที่ได้ด้วยเพิ่ม option ดังตัวอย่าง ดังนี้
<script type="text/javascript">
$(function(){
// แทรกโค้ต jquery
$("#dateInput").datepicker({ dateFormat: 'yy-mm-dd' });
// รูปแบบวันที่ที่ได้จะเป็น 2009-08-16
});
</script>
Code แสดง 2 เดือน
<script type="text/javascript">
$(function(){
// แทรกโค้ต jquery
$("#dateInput").datepicker({
numberOfMonths: 2,
showButtonPanel: true
});
});
</script>
กำหนดช่วงวันที่สามารถเลือกได้
<script type="text/javascript">
$(function(){
// แทรกโค้ต jquery
$("#dateInput").datepicker({minDate: -20, maxDate: '+1M +10D'});
// minDate: -20 ไม่สามารถเลือกวันที่ ก่อน 20 วันก่อนหน้าได้
// maxDate: '+1M +10D' ไม่สามารถเลือก วันที่ถัดจาก อีก 1 เดือนและ 10 วัน ได้
// หากต้องการให้เลือกวันที่ได้เฉพาะวันปัจจุบันเป็นต้นไป
// สามารถกำหนด เป็น $("#dateInput").datepicker({minDate: 0});
});
</script>
บทความคนเข้าอ่านวันนี้
20 Aug 09 jQuery ป้องกัน การคลิกขวา ในหน้าเว็บไซต์ อ่าน 2757 04 Oct 08 การติดตั้ง MySQL บน Windows อ่าน 2944 14 Feb 09 คำนวณหาอายุ จากวันเกิด ด้วย php อ่าน 4476 31 Jul 10 เทคนิค ประยุกต์ใช้ ajax ใน jQuery ร่วมกับ iframe กับการอัพโหลดรูป อ่าน 4316 10 Sep 10 การแสดง ข้อมูลใน infowindows ของ google map ด้วย ajax ใน jQuery อ่าน 3205 13 Oct 08 คำสั่ง SQL IN อ่าน 3101 25 Sep 08 มารู้จัก effect ของ jquery อย่างง่าย ตอนที่ 3 อ่าน 3704 11 Sep 10 จัดรูปแบบ MapTypeControlOptions ใน Google Map อ่าน 1225 25 Sep 08 เริ่มต้นกับ jquery อ่าน 5443 21 Oct 08 php กับการแสดงวันที่เป็นภาษาไทย อ่าน 9617 26 Mar 09 กำหนดข้อความเริ่มต้นให้กับ input text ด้วย jquery อย่างง่าย อ่าน 3200 17 Mar 09 ง่ายๆ กับการส่งค่าตัวแปร PHP ไปใช้ใน Javascript อ่าน 5271 04 Jan 10 ดึงไฟล์ xml (rss) ไฟล์แบบ cross domain มาแสดงด้วย ajax ใน jQuery อย่างง่าย อ่าน 3598 09 Jul 10 เพิ่มความเร็ว ให้กับการ cache ด้วย jquery ajax และ php cache class อ่าน 2265 24 Mar 10 เริ่มต้น รู้จัก ก่อนการใช้งาน google map api อ่าน 5087 25 Sep 08 ปิดหน้า Browser โดยไม่ต้องมีข้อความยืนยัน อ่าน 3649 22 Mar 10 ทบทวนคำสั่ง break และ continue ใน javascript อ่าน 2385 01 Dec 10 การใช้งาน polyline และ polygon ใน google map api v3 อ่าน 3581 27 Dec 10 การสร้าง ajax dictionary จาก longdo ด้วย jQuery อ่าน 2679 21 Aug 09 ตรึงหัวข้อ header ในตาราง table ด้วย css รองรับ Firefox และ IE อ่าน 4804
