时间表的Acrobat javascript

时间:2013-03-25 13:34:49

标签: javascript acrobat

我离开了我的元素,我在每个脚趾上至少两次在黑暗中磕磕绊绊。

我有一个时间表表单,运行Sun到Sat,看起来有点像:

    "Button to fill in dates for the week"
    Sun "Date field" In LunchOut LunchIn Out Total
    Mon "Date field" In LunchOut LunchIn Out Total
    .
    .
    .
    Sat

当我按下按钮时,我希望它填写该周的正确日期,无论我在哪一周推动它。我拼凑了一些我在网上找到的javascript snippits,但我只是没有足够的框架来理解我在做什么......但是,奇怪的是,我觉得我走在正确的轨道上去了

这是我到目前为止所得到的

    function fillDates(){
        var startDay = 0; //0=sunday, 1=monday etc.
    //    var d = now.getDay(); //get the current day
        var d = ("m/d/yy",new Date());
        var weekStart = new Date(now.valueOf() - (d<=0 ? 7-startDay:d-startDay*86400000); //rewind to start day
        var weekd1 = new Date(weekStart.valueOf() + 1*86400000); //add 1 days to get last day
        var weekd2 = new Date(weekStart.valueOf() + 2*86400000); //add 2 days to get last day
        var weekd3 = new Date(weekStart.valueOf() + 3*86400000); //add 3 days to get last day
        var weekd4 = new Date(weekStart.valueOf() + 4*86400000); //add 4 days to get last day
        var weekd5 = new Date(weekStart.valueOf() + 5*86400000); //add 5 days to get last day
        var weekEnd = new Date(weekStart.valueOf() + 6*86400000); //add 6 days to get last day
        this.getField("Sunday").value = weekStart

    //    var sun = this.getField("Sunday");
    //    sun.value = util.printd("m/d/yy",weekStart());
    //    var fld = this.getField("Monday");
    //    fld.value = util.printd("m/d/yy",new Date());
    }
    fillDates();

Acrobat首先在“var d”now.getDay()声明中抱怨“now”,所以我将其更改为下一行(如果可行则没有线索),然后它抱怨了weekStart now.valueOf()和我不确定那是什么引用,没有和例子,我早上没时间。我得到的印象是acrobat的javascript可能只有一部分javascript东西可用而且“now”不包括在内......但这是一个总猜测。

指导?

1 个答案:

答案 0 :(得分:0)

我明白了......

var d = util.printd("dddd",new Date());
switch (d){
case "Sunday":
     d = 0;
     break;
case "Monday":
     d = 1;
     break;
case "Tuesday":
     d = 2;
     break;
case "Wednesday":
     d = 3;
     break;
case "Thursday":
     d = 4;
     break;
case "Friday":
     d = 5;
     break;
case "Saturday":
     d = 6;
     break;
}

var rightNow = new Date();
var msRightNow = rightNow.getTime();
var startDay = 0;
var rightNow = new Date();
var dMS = rightNow.getTime();
var weekStart = new Date(dMS - (d<=0 ? 7-startDay:d-startDay)*86400000);
var msWeekStart = weekStart.getTime();
var weekd2 = new Date(msWeekStart + 1*86400000); //add 1 days to get last day
var weekd3 = new Date(msWeekStart + 2*86400000); //add 2 days to get last day
var weekd4 = new Date(msWeekStart + 3*86400000); //add 3 days to get last day
var weekd5 = new Date(msWeekStart + 4*86400000); //add 4 days to get last day
var weekd6 = new Date(msWeekStart + 5*86400000); //add 5 days to get last day
var weekd7 = new Date(msWeekStart + 6*86400000); //add 6 days to get last day
var sunday = this.getField("Sunday");
sunday.value = util.printd("m/d/yy",weekStart);
var monday = this.getField("Monday");
monday.value = util.printd("m/d/yy",weekd2);
var tuesday = this.getField("Tuesday");
tuesday.value = util.printd("m/d/yy",weekd3);
var wednesday = this.getField("Wednesday");
wednesday.value = util.printd("m/d/yy",weekd4);
var thursday = this.getField("Thursday");
thursday.value = util.printd("m/d/yy",weekd5);
var friday = this.getField("Friday");
friday.value = util.printd("m/d/yy",weekd6);
var saturday = this.getField("Saturday");
saturday.value = util.printd("m/d/yy",weekd7);