从日历jquery获取日期

时间:2012-05-22 09:01:11

标签: javascript jquery

我试图用两个日历与jquery获得两个日期 我怎么能这样做。
代码:

 <div id="checklinkform" data-role="fieldcontain">
                    <label for="checkin">Date début :</label></td>
                         <input name="checkin" id="checkin" data-role="datebox" type="date" data-mini="true"
                                 data-options='{"closeCallback":"linkedCheckin", "noButton": false, "closeCallbackArgs":["checkin"], "mode": "calbox", "focusMode": true, "centerWindow": true, "afterToday": false, "beforeToday":true}'>

                        <input name="checkin_monthday" type="hidden" size="2" id="checkin_monthday" data-mini="true"/>
                        <input name="checkin_year_month" type="hidden" size="7" id="checkin_year_month" data-mini="true"/>

                    <label for="checkout">Date fin :</label></td>   
                        <input name="checkout" id="checkout" data-role="datebox" type="date" data-mini="true"
                                data-options='{"calHighToday":false, "closeCallback":"linkedCheckin", "noButton": false, "closeCallbackArgs":["checkout"], "mode": "calbox", "focusMode": true, "centerWindow": true}'>

                       <input name="checkout_monthday" type="hidden" size="2" id="checkout_monthday" data-mini="true"/>
                       <input name="checkout_year_month" type="hidden" size="7" id="checkout_year_month" data-mini="true"/>

             </div>

编辑。

这里是使用的cheklinkform函数:

linkedCheckin = function (date, name) {
    // The widget itself
var self     = this,
    // The day after whatever just got set
      nextday  = date.copymod([0,0,1]);
    // Today
    today    = new Date();
    // The difference of today and whatever got set (secs)
    diff     = parseInt((date - today) / ( 1000 * 60 * 60 * 24 ),10);
    // The same difference, in days (+2)
    diffstrt = (diff * -1)-2;

// Lets fill in the other fields.
$('#'+name+'_year_month').val(self._formatter('%Y-%m', date));
$('#'+name+'_monthday').val(self._formatter('%d', date));
// Update the seen output
$('#checkoutput').text($('#checklinkform input').serialize());

// If we edited the checkin date, more work to do
if ( name === "checkin" ) {
  // Ok, so in steps: (nuke the comments)
  // Set the (internal) checkout date to be whatever was picking in checkin +1 day
  $('#checkout').data('datebox').theDate = nextday;
  // Show that to the user
  $('#checkout').trigger('datebox', {'method':'doset'});
  // Make sure that minDays won't let them check out same day or earlier
  $('#checkout').datebox({"minDays": diffstrt});
  // Open it up
  $('#checkout').datebox('open');
}
}

我想获得2个日期来发送另一个功能

1 个答案:

答案 0 :(得分:0)

demo is this what you are looking for let me know - click here

如果这是正确的请注释,我将删除我的帖子。

<强>更新

代码

alert(" Date Check in: " + $("#checkin").val());
    alert(" Date Check out: " + $("#checkout").val());
相关问题