Skip to main content
Participating Frequently
June 20, 2024
Answered

I need help with a custom Calculation script

  • June 20, 2024
  • 1 reply
  • 991 views

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

This topic has been closed for replies.
Correct answer Nesa Nurani

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

1 reply

Nesa Nurani
Community Expert
Community Expert
June 20, 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?

Participating Frequently
June 20, 2024

I would like it to be blank 

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
June 20, 2024

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