• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• pdf Forms

# pdf Forms

Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

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)))
;

TOPICS
PDF forms

Views

451

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Expert , Nov 16, 2023 Nov 16, 2023

Try this:

``````var pv = Number(this.getField("PropertyValue").valueAsString);
var d = Number(this.getField("Down").valueAsString);
var cb = this.getField("FHAboxcal").valueAsString;

if(pv && d){
if (cb != "Off")
event.value = pv-(pv*d/100);
else if (cb == "Off")
event.value =((pv-(pv*d/100))+((pv-(pv*d/100))
*(1.75/100)));}
else
event.value = "";``````

Community Expert , Nov 17, 2023 Nov 17, 2023

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);

16 Replies 16
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copied

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".

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

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;

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

It's giving me an error anyway =(

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copied

You doesn't use the variables b and c.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

Thank you i corrected but still gives me an

"SyntaxError: syntax.error6:at line7

do you have any Ideas?

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

Sorry now looks liked this

var b = Number(this.getField("Down").value);
var c = Number(this.getField("PropertyValue").value);
var d = c-(c*b/100)*(1.75/100);
var e= d-(d*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;

and still give a syntax error

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copied

This line doesn't make any sense:

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

You also have a bunch of logical errors in your code.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

Thank you for your input. Im trying to to condition if  "box FHbox"  is checked to do "d" if not, to do "e" I know it must be annoying sorry for that, and thank you so much for your input i have cleaned it as much as I can +

var a = Number(this.getField("FHAboxcal").value);
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)*(1.75/100));
var e= d-(d*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 == "" || b == "" || c == "")
event.value = "";
else
event.value = total;

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copied

I think you mean this:

var total;

if (this.getField("a").value=="Off") total = d;
else total = e;

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

thank you so very much makes way more sense than mine, although still is giving me this

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copied

I'm not getting any syntax errors, although you should remove one of the double semi-colons.

Post your code as text, not an image.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 16, 2023 Nov 16, 2023

Copied

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;

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copied

Try this:

``````var pv = Number(this.getField("PropertyValue").valueAsString);
var d = Number(this.getField("Down").valueAsString);
var cb = this.getField("FHAboxcal").valueAsString;

if(pv && d){
if (cb != "Off")
event.value = pv-(pv*d/100);
else if (cb == "Off")
event.value =((pv-(pv*d/100))+((pv-(pv*d/100))
*(1.75/100)));}
else
event.value = "";``````

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 17, 2023 Nov 17, 2023

Copied

Thank you for taking the time to help me. You are very kind. It works great !!!

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Nov 17, 2023 Nov 17, 2023

Copied

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);

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Nov 17, 2023 Nov 17, 2023

Copied

LATEST

Thank you for your observation. It also works perfectly. I appreciate your time and effort.

Thank you for helping me to grow in this field till next time,