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

I need help with a custom Calculation script

New Here ,
Jun 19, 2024 Jun 19, 2024

I'm making an order form for levels in a supply room. I have a set inventory level say 10. I have a text box to input the level currently on hand. I need to perform a calculation of the difference of the two numbers. That part is easy. I think. So if the level currently on hand is blank then I want the amount to order to be blank or if the amount on hand is equal to our over the amount allowed then it will also be blank. If that makes since. So I was trying to use:

 

var A = this.getField("Text2");

var B = 10

var D = ((var B - var A))

 

But I got a syntex error that I can't figure out and then there is the if statements for the blank text fields. If someone could help I would appreciate it. 

 

Thanks

TOPICS
Create PDFs , PDF , PDF forms
705
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 ,
Jun 19, 2024 Jun 19, 2024

You can try this:

var A = Number(this.getField("Text2").valueAsString);
var B = 10;

if(A == 0 || A == B)
event.value = "";
else
event.value = B-A;

 

What should happen if someone enters more then (B) 10, it should show negative number?

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 ,
Jun 19, 2024 Jun 19, 2024

In that case, just change: A == B to: A >= B

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 ,
Jun 19, 2024 Jun 19, 2024

You can try this:

var A = Number(this.getField("Text2").valueAsString);
var B = 10;

if(A == 0 || A == B)
event.value = "";
else
event.value = B-A;

 

What should happen if someone enters more then (B) 10, it should show negative number?

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
New Here ,
Jun 19, 2024 Jun 19, 2024

I would like it to be blank 

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 ,
Jun 19, 2024 Jun 19, 2024

In that case, just change: A == B to: A >= B

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
New Here ,
Jun 20, 2024 Jun 20, 2024
LATEST

I am still unable to get this formula to work. Is there any way I could emal you the test PDF I am using to see if you could get it to work? if you have Adobe Acrobat Pro that is?

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