使用DatePicker Oracle Apex上的Dynamic Action比较日期 [英] Comparing dates using Dynamic Action on DatePicker Oracle Apex

查看:453
本文介绍了使用DatePicker Oracle Apex上的Dynamic Action比较日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日期选择器,用户只需选择一个日期,那么如果用户点击明天(sysdate + 1),动态动作就会发送警报。



Datepicker术语是简单的布局。



动态动作 - >


名称:有效日期



事件:更改



选择类型:项目



Item(s):datepicker_name



条件:等于



值:sysdate + 1


当我运行程序并点击日历上的任何一天,没有提醒。我以为问题是格式。动态动作将日期看作DD / MM / YYYY,而Datepickers输出为DD-Mon-YY,因此无法比较。苹果和橘子但是我用格式玩弄了所有的相同但仍然没有进展。



再次感谢你的时间和帮助!

解决方案

As @ScottWe提到:你试图在HTML / javascript中应用PLSQL逻辑。 'When - Condition'在运行时被评估,因此你不能在那里使用PLSQL。
日期算术在JavaScript中有点恼人,所以如果你不熟悉,这里是一种方式可以执行你的支票(即是明天的输入日期)。

从我的线索:

Javascript中的日期差异(忽略每天的时间)

JavaScript如何以格式dd-mm-yy获取明天日期



将这个函数添加到页面的JavaScript部分,以获取全局变量和函数:

  function isTomorrow(pDateItem){
function getTomorrow(){
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate()+ 1);
明天回来
};

函数cutTime(pDate){
返回新日期(pDate.getFullYear(),pDate.getMonth(),pDate.getDate());
};

//检查pDateItem是否导致选择
//检查是否是datepicker
//检查是否已选择日期
if($( pDateItem).length
&&$(pDateItem).data(datepicker)
&& $(pDateItem).datepicker(getDate)!== null

{
var tomorrow = getTomorrow();
var check = $(pDateItem).datepicker(getDate);
var one = cutTime(check);
var two = cutTime(tomorrow);

return one.getDate()=== two.getDate();
};
返回false;
}

然后在动态动作When条件下,使用一个javascript表达式代码:

  isTomorrow(this.triggeringElement)

然后,当日期设置为明天时,相应的True Actions才会触发。


I have a date picker where the user simply chooses a date then a Dynamic Action is suppose to send an alert if the user clicks tomorrow(sysdate+1).

The Datepicker term is the simple layout.

The Dynamic Action-->

Name: Valid Date

Event: Change

Selection type: Item(s)

Item(s): datepicker_name

Condition: equal to

Value: sysdate+1

When I run the program and click any day on the calendar, no alert comes up. I thought the problem was the format. The Dynamic Action sees the date as "DD/MM/YYYY" while the Datepickers output is "DD-Mon-YY" so it could not compare them. Apples and Oranges. But I played around with the format to make it all the same but still no progress.

Thanks again for your time and help!

解决方案

As @ScottWe mentions: you're trying to apply PLSQL logic in HTML/javascript. The 'When - Condition' is evaluated at runtime and thus you can't use PLSQL there. The date arithmetic is a bit annoying in javascript though, so if you're a unfamiliar with it, here is a way you can perform your check (which is, is the entered date tomorrow or not).

Taking my clues from these:
Date difference in Javascript (ignoring time of day)
JavaScript how to get tomorrows date in format dd-mm-yy

Add this function to the page's javascript section for global variables and functions:

function isTomorrow(pDateItem){  
  function getTomorrow(){ 
    var tomorrow = new Date();
    tomorrow.setDate(tomorrow.getDate() + 1);
    return tomorrow;
  };

  function cutTime(pDate){
    return new Date(pDate.getFullYear(), pDate.getMonth(), pDate.getDate());
  };

  // check if pDateItem leads to a selection
  // check if it is a datepicker
  // check if a date has been selected
  if ( $(pDateItem).length 
       && $(pDateItem).data("datepicker")
       && $(pDateItem).datepicker("getDate") !== null 
     ) 
  {        
    var tomorrow = getTomorrow();
    var check = $(pDateItem).datepicker("getDate");
    var one = cutTime(check);
    var two = cutTime(tomorrow);

    return one.getDate() === two.getDate();
  };
  return false;
}

Then in your Dynamic action 'When' condition, use a javascript expression with this code:

isTomorrow(this.triggeringElement)

Then the corresponding True Actions will only fire when the date is set to tomorrow.

这篇关于使用DatePicker Oracle Apex上的Dynamic Action比较日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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