2013-03-25 45 views
1

我在這裏擺脫了我的元素,我在每個腳趾上至少兩次磕磕碰碰,在黑暗中徘徊。Acrobat javascript時間表

我有一個運行週日到週六,看起來有點像一個時間表形式:

"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中的「變種d」 now.getDay()聲明首先抱怨「現在」,所以我就改到下一行(不知道如果這將工作),然後它抱怨weekStart now.valueOf(),我不確定那是指什麼,沒有和示例,並在早上時間。我得到的印象是,acrobat的JavaScript可能只有一部分javascript的東西可用,「現在」不包括在內......但這是一個總的猜測。

指導?

+0

羅布,如果你有一個建議,它看起來並不像它已成功發佈 – user30772 2013-03-25 20:52:37

回答

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); 
相關問題