1
我被格式化jQuery UI日曆的問題困住了。日曆的格式基於用戶偏好。如果用戶選擇從第一個選擇框中的日期格式,那麼UI日曆格式,應根據該...請就如何實現這一想法..在此先感謝..問題格式化jQuery UI日曆
jQuery代碼
jQuery(function() {
var format = 'yy-mm-dd';
jQuery('#dateFormat').change(function(){
format = jQuery('#dateFormat').val();
alert(format);
});
jQuery('#fromDate').datepicker({
showTime: false,
dateFormat: format,
showOn: 'button',buttonText: 'Date', buttonImage: 'images/calendar.gif', buttonImageOnly: true
});
jQuery('#toDate').datepicker({
showTime: false,
dateFormat: 'dd-mm-yy',
showOn: 'button',buttonText: 'Date', buttonImage: 'images/calendar.gif', buttonImageOnly: true
});
});
HTML代碼如下
<label>Date Format</label>
<select name="dateFormat" id="dateFormat">
<option val="1">dd-mm-yy</option>
<option val="2">yy-mm-dd</option>
</select>
<label>Period start:</label>
<input type="text" value="" size="30" name="fromDate" id="fromDate" />
<label>Period start:</label>
<input type="text" value="" size="30" name="toDate" id="toDate" />
非常感謝。它的工作很好,唯一的事情是,腳本對變化的反應非常緩慢.. :-) – Sullan 2010-07-21 07:48:29
我編輯了代碼並做了一些優化,現在就試試吧 – GerManson 2010-07-21 17:36:03