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

pdf Forms

Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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

938

Translate

Translate

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 guidelines

correct answers 2 Correct answers

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 = "";

Votes

Translate

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

Votes

Translate

Translate
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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;

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

Copied

It's giving me an error anyway =(

 

Votes

Translate

Translate

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 guidelines
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

Copied

You doesn't use the variables b and c. 

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

Copied

Thank you i corrected but still gives me an

 

"SyntaxError: syntax.error6:at line7 

 

do you have any Ideas?

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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

 

Votes

Translate

Translate

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 guidelines
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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.

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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;

 

Votes

Translate

Translate

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 guidelines
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

Copied

I think you mean this:

 

var total;

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

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

Copied

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

Akxelem32911425ilk8_0-1700178551781.png

 

 

Votes

Translate

Translate

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 guidelines
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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.

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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;

Votes

Translate

Translate

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 guidelines
Community Expert ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

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 = "";

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 17, 2023 Nov 17, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

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 guidelines
Community Expert ,
Nov 17, 2023 Nov 17, 2023

Copy link to clipboard

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

Votes

Translate

Translate

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 guidelines
Explorer ,
Nov 17, 2023 Nov 17, 2023

Copy link to clipboard

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,

Votes

Translate

Translate

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 guidelines