Hello all, new here as you can tell. Also don't have much experience with JS. Only been in Java/C++/MATLAB classes so far.
I've got two text forms on Acrobat Pro, STRENGTHMOD and STR. I was wondering if there was a way to take the user-entered value from STR and:
divide by 2
subtract 5
then round up
and place that result in STRENGTHMOD using a calculation in JS?
In STRENGTHMOD, what I have so far (not working btw) is:
var ability = this.getField("STR");
var mod = (ability.value/2) - 5;
event.value=Math.ceil(mod.value);
Any and all help is very appreciated,
Adam
// get field object
var ability = this.getField("STR");
// divide field's value by 2 and subtract 5
var mod = (ability.value / 2) - 5;
// format for rounding result
var cFormat = "%,1 .2f"
// format result
event.value = util.printf(cFormat, mod);
// some debugging:
console.show();
console.clear();
console.println('ability value: ' + ability.value);
console.println('mod (ability.value / 2) - 5: ' + ((ability.value / 2) - 5));
console.println('rounded with util.printf: ' + util.printf(cFormat, mod));
var nDecAdj = Math.pow(10, 2);
console.println('mod dec adjustment: ' + (mod * nDecAdj));
console.println('Math.round(' + (mod * nDecAdj) + '): ' + (Math.round(mod * nDecAdj)));
console.println('Shift decimal point back: ' + (Math.round(mod * nDecAdj) / nDecAdj));
George Kaiser