【问题标题】:Open two jquery datepickers simultaneously同时打开两个jquery datepickers
【发布时间】:2012-05-21 13:39:31
【问题描述】:

我有两个输入字段,其中包含一个触发日期选择器打开的类。两者都可以独立工作,即当我单击一个或另一个时,但我希望在单击任一输入字段时打开两个日期选择器。

这是代码的脚本部分

    $(document).ready(function() {

                    $( ".datefields" ).datepicker({ dateFormat: 'dd/mm/yy',numberOfMonths: 1, yearRange: "2012:2014", changeYear: true, changeMonth: true});        

这是html

<div id="quoteformcollection">
<h1>Collection</h1>

<input type"text" class="startTbl locationfields" id="AutoLocStart" value="Please Type a Collection Location"onclick="clearVal(this);"/>
    <input type="hidden" id="DepotStart" value=""/></td>

<input type="text" class="datefields" id="collectiondate" value="21/05/2012"/>
<input type"text" class="timefields" value="12:00" />
</div> 

<div id="quoteformreturn">
<h1>Return</h1>

<input type"text" class="locationfields" value="Enter the city or location for return" />
<input type"text" id="returndate" class="datefields" value="21/05/2012" />
<input type"text" class="timefields" value="12:00" />
</div>

我自己尝试过寻找答案,但对 jquery 还是很陌生并且有点挣扎,因此非常感谢任何帮助。

我还希望在第一个日期选择器中选择任何值,第二个中的默认日期增加 x 天数,我也不确定最好的方法。

任何建议将不胜感激!

【问题讨论】:

    标签: javascript jquery uidatepicker


    【解决方案1】:

    试试这个代码来链接两个数据选择器:

    $('#collectiondate').datepicker({
        dateFormat: "@",
        onSelect: function(dateText, inst) {
            var dateText = eval(dateText);
            var min = new Date();
            min.setTime(dateText);
            $('#end').datepicker('option', 'minDate', min);
        }
    });
    
    $('#returndate').datepicker({
        dateFormat: "@",
    });
    

    【讨论】:

      【解决方案2】:

      我认为您必须使用“内联”日历并通过 jQuery / Javascript 自己管理它的弹出方式。您需要将 cal 指向一个 div 标签才能内联使用它。

      http://jqueryui.com/demos/datepicker/#inline

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多