Skip to main content
Known Participant
November 16, 2023
Answered

pdf Forms

  • November 16, 2023
  • 1 reply
  • 2458 views

Hello, everyone. im trying to add a formula to a box depending on the value of a check box. I did it this way, but it is not working. Can someone please help

 

if (this.getField("FHAboxcal").value!="Off") event.value=(PropertyValue-(PropertyValue*Down/100))
;
else if (this.getField("FHAboxcal").value!="On") event.value=((PropertyValue-(PropertyValue*Down/100))+( (PropertyValue-(PropertyValue*Down/100))
*(1.75/100)))
;

This topic has been closed for replies.
Correct answer try67

try67. I appreciate your help on this one. I changed it to a simpler way, and it still gives me an error now in "var e = " I know that I have been a pain in the butt please take a last look I appreciate it:

 

var a = Number(this.getField("FHAboxcal").value);
var b = Number(this.getField("Down").value);
var c = Number(this.getField("PropertyValue").value);
var d = c-((c*b/100)));
var e = d*0.0175;
var f = d+e
var total = if (this.getField("a").value=="Off") total = d;
else total = f;
;;
if(a == "" || b == "" || c == "")
event.value = "";
else
event.value = total;


The error is in this line:

var d = c-((c*b/100)));

You have one too many closing brackets. Use this:

var d = c-(c*b/100);

1 reply

Nesa Nurani
Inspiring
November 16, 2023

Are 'PropertyValue' and 'Down' field names?

If yes, you also need to use this.getField() to get their values, same as you did for checkbox.

For 'else if' part, if you added export value to be 'On' it's ok if not, check that value is equal to "Off".

Known Participant
November 16, 2023

Thank you so much. Do you mean something like this?

 

var a = Number(this.getField("FHAboxcal").value);

var b = Number(this.getField("Down").value);

var c = Number(this.getField("PropertyValue").value);

var d = PropertyValue-(PropertyValue*Down/100)

*(1.75/100);

var e= PropertyValue-(PropertyValue*Down/100);

var total = if (this.getField("a").value!="Off") event.value=e;

else if (this.getField("a").value!="On") event.value=d

;;

if(a == "" || ir == "" || lt == "")

event.value = "";

else

event.value = total;

Known Participant
November 16, 2023

It's giving me an error anyway =(