I'm having a real difficult time figuring this out:
I want to use the ceiling formula to do the following:
User enters a number, the ceiling calculation will then round it up to the nearest 50.
The name of the field is: fldVbmEnvelopeOrderQty5
This is what I have under show "Enter", language = Javascript. Run at: Client
IFS.Page5.fldVbmEnvelopeOrderQty5 = Math.ceil(50)
Data format: Integer
Default Binding: Normal
Type: User Entered - Optional
Yes I've read multiple threads on it, and NO none of the links on those threads helped.
// num = 0, result = 0
// num = 1, result = 50
// num = 49, result = 50
// num = 50, result = 50
// num = 501, result = 550
var inc = 50;
var num = 89;
var result = (num % inc) ? num + (inc - (num % inc)) : num;
// result is 100
The % operator is the modulus operator in JavaScript. The code rounds up to the nearest increment if there's a remainder. Otherwise, it doesn't need to. That last line is equivalent to:
// If there's a remainder...
if (num % inc) {
result = num + (inc - (num % inc));
} else {
result = num; // No remainder
}