Copy link to clipboard
Copied
Hello, I am trying to assign a formula. If a box is checked, I'll do the following: Anyone may help, please.
var a = Number(this.getField("OT 1st").valueAsString);
var b = Number(this.getField("Rate x Hour 1st").valueAsString);
if(b){
if (cb != "Off")
event.value ="";
else if (cb == "Off")
event.value =(a*1.50);}
Copy link to clipboard
Copied
From the quick glance at your script I can see couple of issues:
1. You defined three variables (a, b, c), but b is not used in the calculations.
2. You used two conditions (a<=0 and a>=0), which are exhaustive and include all possibilities, so the second condition (else if (a>=0)) is effectively redundant.
You can simplify this by using if...else.
3. There is a typographical error in event.value =””; where the quotation marks are not the standard ones used they should be "".
Copy link to clipboard
Copied
You forgot to declare 'cb' variable.
And what is the point of 'b' variable, you only use it for condition?.
Copy link to clipboard
Copied
hank you for your solution. However, it is still not working for me. I tried simplifying it using this method, but it didn't work either. Could you please help me when you have a moment?
var a = Number(this.getField("HrsOT1stPeriod").value);
var b = Number(this.getField("OTfirst period").value);
var c = Number(this.getField("Rate x Hour 1st").value);
if (a<=0)
event.value =””;
else if (a>=0)
event.value =((c*1.50)*a)
What I'm looking for is if there is overtime to show the regular time times 1.5 and multiplied by the hours
Copy link to clipboard
Copied
From the quick glance at your script I can see couple of issues:
1. You defined three variables (a, b, c), but b is not used in the calculations.
2. You used two conditions (a<=0 and a>=0), which are exhaustive and include all possibilities, so the second condition (else if (a>=0)) is effectively redundant.
You can simplify this by using if...else.
3. There is a typographical error in event.value =””; where the quotation marks are not the standard ones used they should be "".
Copy link to clipboard
Copied
Thank you for your solution. However, it is still not working for me. I tried simplifying it using this method, but it didn't work either. Could you please help me when you have a moment?
var a = Number(this.getField("HrsOT1stPeriod").value);
var b = Number(this.getField("OTfirst period").value);
var c = Number(this.getField("Rate x Hour 1st").value);
if (a<=0)
event.value =””;
else if (a>=0)
event.value =((c*1.50)*a)
What I'm looking for is if there is overtime to show the regular time times 1.5 and multiplied by the hours
Find more inspiration, events, and resources on the new Adobe Community
Explore Now