[英]Jquery datepicker - year then month then day
I am trying to use datepicker by http://foundation-datepicker.peterbeno.com/example.html to get the user to select a date. 我正在尝试通过http://foundation-datepicker.peterbeno.com/example.html使用datepicker来使用户选择日期。
The datepicker has a really nice year-picker and month-picker format instead of using the arrows, it has a nice selector. datepicker具有非常好的年份选择器和月份选择器格式,而不是使用箭头,它具有一个不错的选择器。
the only way to access the year picker I can tell is to click on the year at the top, however I want this to show first on default. 我知道的访问年份选择器的唯一方法是单击顶部的年份,但是我希望默认显示为第一。 once the user selects the year, then allow them to select the month using the month-picker
一旦用户选择了年份,然后允许他们使用月份选择器选择月份
[month-picker][2] - 2: i.stack.imgur.com/CiIgU.png (i am unable to post more than 2 links currently as I am new to stackoverflow but here is the intended screenshot - same as below...) [month-picker] [2]-2:i.stack.imgur.com/CiIgU.png(由于我是stackoverflow的新手,因此我目前无法发布2个以上的链接,但这是预期的屏幕截图-如下所示。 ..)
I want them to first select the year, then the month, then day. 我希望他们先选择年份,然后选择月份,然后选择日期。 However all the examples I see I don't see how to set all three beginning with year.
但是,我看到的所有示例都看不到如何从年份开始设置这三个示例。
then finally the default day picker 然后最后是默认的日期选择器
[day-picker][3] - 3: i.stack.imgur.com/p3re2.png [day-picker] [3]-3:3:i.stack.imgur.com/p3re2.png
Alternatively if the above is not possible could allow the user to select 3 separate times with 3 different datepickers - one for year, month, and day. 或者,如果上述操作不可行,则可能允许用户使用3种不同的日期选择器来选择3次单独的时间-一种用于年,月和日。 I can get the month-picker only working with the following (but not the year picker):
我只能在以下情况下使用月份选择器(但不能使用年份选择器):
<div class="row collapse date" id="dpMonths" data-date-format="mm/yyyy" data-start-view="year" data-min-view="year" style="max-width:200px;">
<div class="small-2 columns">
<span class="prefix"><i class="fa fa-calendar"></i></span>
</div>
<div class="small-10 columns">
<input size="16" type="text" value="02/2012" readonly>
</div>
<script>
$(function(){
$('#dpMonths').fdatepicker();
});
</script>
Is this possible? 这可能吗?
There is tons of examples on this page, but if i try modify any of them it either breaks or doesnt do what I need it to do... 此页面上有大量示例,但是如果我尝试修改其中的任何一个,它要么中断要么不执行我需要做的事情...
Kind regards, Dave 亲切的问候,戴夫
The examples on the website above are not correct. 上面网站上的示例不正确。 I have managed to find the answer in one of the commits after much searching.
经过大量搜索,我设法在提交之一中找到了答案。 Hopefully this answer may assist someone else.
希望这个答案可以帮助其他人。
$('.monthpicker').fdatepicker({
format : 'mm/yyyy',
startView : 1,
minView : 1
});
The views are numbered go up so 4 = year etc. 视图编号编号为4 =年等。
To select date going through year -> month -> day: 要选择通过年->月->日的日期:
$('.monthpicker').fdatepicker({
format : 'mm/yyyy',
startView : 4,
minView : 2
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.