|
|
|
สอบถาม datepicker เวอชั่นใหม่ครับ input ในช่องกลายเป็นปี คศ ครับ |
|
|
|
|
|
|
|
ลองใช้ของผมดูครับ วางไฟล์ผมไว้ล่างสุด
<script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/jquery-ui.min.js'></script>
<script type='text/javascript' src='js/jquery-thaidatepicker.js'></script>
jquery-thaidatepicker.js
var dateBefore = null;
$.datepicker.setDefaults({
showOn: "both",
buttonImage: "images/calendar.gif",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
dayNamesMin: ['อา', 'จ', 'อ', 'พ', 'พฤ', 'ศ', 'ส'],
monthNames: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
monthNamesShort: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
beforeShow:function(){
var altFieldId = $(this).attr("id")+"display";
if(typeof $("#"+altFieldId).val() === "undefined"){
var altField = $(this).clone();
$(altField).attr("id", altFieldId);
$(this).before(altField);
$(this).hide();
$("#"+altFieldId).on("focus", function(){
$("#"+altFieldId.replace("display", "")).trigger("focus");
});
}
if($(this).val()!=""){
var now = new Date();
var arrayDate=$(this).val().split("-");
arrayDate[0]=parseInt(arrayDate[0])+543;
$("#"+altFieldId).val(arrayDate[2]+"/"+arrayDate[1]+"/"+arrayDate[0]);
}
setTimeout(function(){
var textYear = parseInt($("span.ui-datepicker-year").html())+543;
$("span.ui-datepicker-year").html(textYear);
$.each($(".ui-datepicker-year option"),function(j,k){
var textYear=parseInt($(".ui-datepicker-year option").eq(j).val())+543;
$(".ui-datepicker-year option").eq(j).text(textYear);
});
},50);
},
onChangeMonthYear: function(){
setTimeout(function(){
var textYear = parseInt($("span.ui-datepicker-year").html())+543;
$("span.ui-datepicker-year").html(textYear);
$.each($(".ui-datepicker-year option"),function(j,k){
var textYear=parseInt($(".ui-datepicker-year option").eq(j).val())+543;
$(".ui-datepicker-year option").eq(j).text(textYear);
});
},50);
},
onClose:function(dateText, inst){
if($(this).val()!="" && $(this).val()==inst.lastVal){
var altFieldId = $(this).attr("id")+"display";
var arrayDate=inst.lastVal.split("-");
arrayDate[0]=parseInt(arrayDate[0])+543;
$("#"+altFieldId).val(arrayDate[2]+"/"+arrayDate[1]+"/"+arrayDate[0]);
}
},
onSelect: function(dateText, inst){
var altFieldId = $(this).attr("id")+"display";
var arrayDate=dateText.split("-");
arrayDate[0]=parseInt(arrayDate[0])+543;
$("#"+altFieldId).val(arrayDate[2]+"/"+arrayDate[1]+"/"+arrayDate[0]);
}
});
$.fn.setDate = function(date){
this.datepicker("setDate", date);
var altFieldId = $(this).attr("id")+"display";
var altField = $(this).clone();
$(altField).attr("id", altFieldId);
$(this).before(altField);
$(this).hide();
$("#"+altFieldId).on("focus", function(){
$("#"+altFieldId.replace("display", "")).trigger("focus");
});
var arrayDate=$(this).val().split("-");
arrayDate[0]=parseInt(arrayDate[0])+543;
$("#"+altFieldId).val(arrayDate[2]+"/"+arrayDate[1]+"/"+arrayDate[0]);
};
|
|
|
|
|
Date :
2015-05-12 17:10:06 |
By :
kerb |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้ครับ error อะ
นี่โค้ดผมครับ
ผมแก้ตรง <option value='"+f+"'"+(f===i?" selected='selected'":"")+">"+(f+543)+"</option>
จาก +f+ เป็น +(f+543)+ เหลือแค่ตรง input มะรู้เติมตรงไหน นั่งแกะตั้งแต่เช้าจนมืดด ใครพอมองออกบ้างช่วยหน่อยครับ
++ ผมมือใหม่ครับ
ผมเริ่มหาที่แก้ตั้งแต่ที่หาคำว่า generateMonthYearHeader ตามด้านบนเขียนไว้ครับ
Code (JavaScript)
_generateMonthYearHeader:function(e,t,i,s,a,n,o,r){var h,l,u,d,c,p,f,m,g=this._get(e,"changeMonth"),v=this._get(e,"changeYear"),y=this._get(e,"showMonthAfterYear"),b="<div class='ui-datepicker-title'>",_="";if(n||!g)_+="<span class='ui-datepicker-month'>"+o[t]+"</span>";else{for(h=s&&s.getFullYear()===i,l=a&&a.getFullYear()===i,_+="<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>",u=0;12>u;u++)(!h||u>=s.getMonth())&&(!l||a.getMonth()>=u)&&(_+="<option value='"+u+"'"+(u===t?" selected='selected'":"")+">"+r[u]+"</option>");_+="</select>"}if(y||(b+=_+(!n&&g&&v?"":" ")),!e.yearshtml)if(e.yearshtml="",n||!v)b+="<span class='ui-datepicker-year'>"+(i)+"</span>";else{for(d=this._get(e,"yearRange").split(":"),c=(new Date).getFullYear(),p=function(e){var t=e.match(/c[+\-].*/)?i+parseInt(e.substring(1),10):e.match(/[+\-].*/)?c+parseInt(e,10):parseInt(e,10);
return isNaN(t)?c:t},f=p(d[0]),m=Math.max(f,p(d[1]||"")),f=s?Math.max(f,s.getFullYear()):f,m=a?Math.min(m,a.getFullYear()):m,e.yearshtml+="<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";m>=f;f++)e.yearshtml+="<option value='"+f+"'"+(f===i?" selected='selected'":"")+">"+(f+543)+"</option>";e.yearshtml+="</select>",b+=e.yearshtml,e.yearshtml=null}return b+=this._get(e,"yearSuffix"),y&&(b+=(!n&&g&&v?"":" ")+_),b+="</div>"},_adjustInstDate:function(e,t,i){var s=e.drawYear+("Y"===i?t:0),a=e.drawMonth+("M"===i?t:0),n=Math.min(e.selectedDay,this._getDaysInMonth(s,a))+("D"===i?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(s,a,n)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),("M"===i||"Y"===i)&&this._notifyChange(e)},_restrictMinMax:function(e,t){var i=this._getMinMaxDate(e,"min"),s=this._getMinMaxDate(e,"max"),a=i&&i>t?i:t;return s&&a>s?s:a},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return null==t?[1,1]:"number"==typeof t?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return new Date(e,t,1).getDay()},_canAdjustMonth:function(e,t,i,s){var a=this._getNumberOfMonths(e),n=this._daylightSavingAdjust(new Date(i,s+(0>t?t:a[0]*a[1]),1));return 0>t&&n.setDate(this._getDaysInMonth(n.getFullYear(),n.getMonth())),this._isInRange(e,n)},_isInRange:function(e,t){var i,s,a=this._getMinMaxDate(e,"min"),n=this._getMinMaxDate(e,"max"),o=null,r=null,h=this._get(e,"yearRange");return h&&(i=h.split(":"),s=(new Date).getFullYear(),o=parseInt(i[0],10),r=parseInt(i[1],10),i[0].match(/[+\-].*/)&&(o+=s),i[1].match(/[+\-].*/)&&(r+=s)),(!a||t.getTime()>=a.getTime())&&(!n||t.getTime()<=n.getTime())&&(!o||t.getFullYear()>=o)&&(!r||r>=t.getFullYear())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t="string"!=typeof t?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,i,s){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var a=t?"object"==typeof t?t:this._daylightSavingAdjust(new Date(s,i,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),a,this._getFormatConfig(e))}}),e.fn.datepicker=function(t){if(!this.length)return this;e.datepicker.initialized||(e(document).mousedown(e.datepicker._checkExternalClick),e.datepicker.initialized=!0),0===e("#"+e.datepicker._mainDivId).length&&e("body").append(e.datepicker.dpDiv);var i=Array.prototype.slice.call(arguments,1);return"string"!=typeof t||"isDisabled"!==t&&"getDate"!==t&&"widget"!==t?"option"===t&&2===arguments.length&&"string"==typeof arguments[1]?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i)):this.each(function(){"string"==typeof t?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this].concat(i)):e.datepicker._attachDatepicker(this,t)}):e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i))},e.datepicker=new i,e.datepicker.initialized=!1,e.datepicker.uuid=(new Date).getTime(),e.datepicker.version="1.10.4"})(jQuery);
|
ประวัติการแก้ไข 2015-05-12 21:38:24 2015-05-12 21:40:38 2015-05-12 21:42:48
|
|
|
|
Date :
2015-05-12 21:37:08 |
By :
lhumdin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|