lundi 2 juillet 2018

Using getTime to calculate multiple Dates with If Else statements

I am working in Adobe Acrobat DC on a fillable PDF form and new to JavaScript. I need the value to be $100 until 9/21/2018, then from 9/22 - 10/19 to be $125 and then beginning on 10/20 to be $150.

I have the script below which works for the first If statement, but it does not calculate the 10/20/2018 portion of the script. Can someone please help me and tell me what I am doing wrong? THANK YOU SO MUCH!!

var sub = 100 * Number(this.getField("numEthernet").value);    
var s = this.getField("Date").valueAsString;   
if (s!="") {  
    var d = util.scand("mm/dd/yyyy", s);  
    var cutOffDate = util.scand("mm/dd/yyyy", "9/21/2018");  
    if (d.getTime()>cutOffDate.getTime()){   
        sub *= 1.25;  
    }
}  
else if (s!="") {  
    var d = util.scand("mm/dd/yyyy", s);  
    var cutOffDate = util.scand("mm/dd/yyyy", "10/20/2018");  
    if (d.getTime()>=cutOffDate.getTime()){   
        sub *= 1.50;  
    }  
}
event.value = sub;

Aucun commentaire:

Enregistrer un commentaire