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

pdf Forms

Explorer ,
Nov 16, 2023 Nov 16, 2023

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
1.8K
Translate
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
2 ACCEPTED SOLUTIONS
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 = "";

View solution in original post

Translate
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

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

View solution in original post

Translate
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

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

Translate
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

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;

Translate
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

It's giving me an error anyway =(

 

Translate
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

You doesn't use the variables b and c. 

Translate
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

Thank you i corrected but still gives me an

 

"SyntaxError: syntax.error6:at line7 

 

do you have any Ideas?

Translate
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

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

 

Translate
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

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.

Translate
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

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;

 

Translate
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

I think you mean this:

 

var total;

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

Translate
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

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

Akxelem32911425ilk8_0-1700178551781.png

 

 

Translate
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

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.

Translate
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

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;

Translate
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

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

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

Translate
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

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

Translate
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
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,

Translate
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