日期范围选取器 - 根据日期和时间范围动态更改标签值 [英] Date Range Picker - Dynamically change label value based on date and time range

查看:117
本文介绍了日期范围选取器 - 根据日期和时间范围动态更改标签值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

所以,我正在为机场停车场开发一个基于网络的应用程序。我正在使用Twitter引导程序。要获取我正在使用的每个查询的日期和时间范围引导程序的日期范围选择器。我想要做的是动态更改标签的值总价格,可在预订页面中找到,具体取决于日期范围选择器的输入(位于在顶端)。浏览他们的文档我找不到类似于我的情况。充电率为每小时0.01。例如:如果我正在查询过程中,我选择在周六10(00:00)停车,并在周日11(00:00)取车,价格标签应显示24€ 。



我的理解是,这可能是我要求的太多,但我尽可能地尝试了没有结果。提前谢谢。

Hello everyone.
So, I am developing a web based application for an airport parking. I am using Twitter bootstrap for the form. To get the date and time range of every enquiry I am using Date Range Picker for Bootstrap. What I would like to do is to dynamically change a label's value called "Total Price" which is found in the booking page based on the Date Range Picker's inputs (located on the top). Browsing their documentation I could not find something similar to my case. The charging rates are 0.01 per hour. For example: In case I am in the process of my enquiry and I choose to drop my car off at Saturday 10 (00:00) and pick it up at Sunday 11 (00:00) the price label should display "24€".

It is my understanding that this might me too much to ask but I tried as far as I could with no result. Thank you in advance.

推荐答案

var startDate = "", endDate = "";


' #dateTimeRange ')。daterangepicker({
startDate 2015年9月30日
endDate 2015年6月10日
}, function (开始,结束,标签){
// console.log(选择新日期范围:'+ start.format('YYYY-MM-DD')+'到'+ end.format('YYYY- MM-DD')+'(预定义范围:'+ label +'));
startDate = start.format(' < span class =code-string> YYYY-MM-DD');
endDate = end.format(' YYYY-MM-DD');
});

var dateDiff = 数学 .abs(startDate.getTime() - endDate .getTime())/ 3600000 ;

// 然后根据 dateDiff 执行操作。
('#dateTimeRange').daterangepicker({ "startDate": "09/30/2015", "endDate": "10/06/2015" }, function(start, end, label) { //console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')"); startDate = start.format('YYYY-MM-DD'); endDate = end.format('YYYY-MM-DD'); }); var dateDiff = Math.abs(startDate.getTime() - endDate.getTime()) / 3600000; // and then perform your operation based on dateDiff.



-KR


-KR


这篇关于日期范围选取器 - 根据日期和时间范围动态更改标签值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆