|
 |
|
สอบถาม Script ที่สามารถ กำหนดวัน ของ Datepicker ได้ครับ |
|
 |
|
|
 |
 |
|
ผมโหลด jQuery Datepicker มาใช้ครับ แล้วคราวนี้ผมอยากให้ ผู้ใช้งานสามารถเลือก วันที่ตามที่เรากำหนดได้ครับ
เช่น เลือกได้ตั้งแต่วันที่ 17 มิถุนายน 2554 ถึง 17 สิงหาคม 2554 +++ โดยวันที่ผ่านไปแล้วไม่สามารถเลือกได้ครับ +++
อยยากทราบว่าต้องเขียน java script อย่างไรครับ
นี่คือCodeที่ผมมีครับ
Code (PHP)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Select a Date Range</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.5.1.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
/////////////////////// ไม่ให้เลือกวันก่อนวันที่ำด้เลือกไปแล้ว
$(function()
{
$('.date-pick').datePicker()
$('#start-date').bind(
'dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
$('#end-date').dpSetStartDate(d.addDays(1).asString());
}
}
);
$('#end-date').bind(
'dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
$('#start-date').dpSetEndDate(d.addDays(-1).asString());
}
}
);
});
</script>
</head>
<body>
<div class="demo">
<label for="from">From</label>
<input type="text" id="from" name="from"/>
<label for="to">to</label>
<input type="text" id="to" name="to"/>
</div><!-- End demo -->
<div class="demo-description">
<p>Select the date range to search for.</p>
</div><!-- End demo-description -->
</body>
</html>
Tag : HTML/CSS, JavaScript, jQuery

|
|
 |
 |
 |
 |
Date :
2011-06-17 12:19:58 |
By :
narongkub |
View :
2158 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
var dates = $( "#from, #to" ).datepicker({
dateFormat: 'yy-mm-dd',
maxDate:'+1M'
|
 |
 |
 |
 |
Date :
2011-06-17 13:59:24 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอ๊า .. พี่ก็ติดสคริปเก่าเราไปตั้งบรรทัดหนึ่งอ่ะครับ ดูไม่ออกใช่ไม๊เนี่ย
|
 |
 |
 |
 |
Date :
2011-06-17 18:04:55 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เข้าไปดู document ของ date picker ครับ มันมี options ให้ดู ดูตรง mindate , maxdate
|
 |
 |
 |
 |
Date :
2011-06-18 17:37:29 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|