Inconsistent performance of custom calculation script
I am new to both PDF form and JavaScript, so I apologize if this question seems obvious, or isn't worded effectively.
I'm attempting to create a custom text field which will calculate the user's "Star Wars Galactic Birth Year" as part of a PDF form. Basically, type in your age, and it will spit out your "birth year", appended with BBY or ABY depending on if the number is positive or negative. (35ABY acting as the "current" year, in this example.) Here's the custom script I cobbled together. ("Age" is the name of the field, as I'm sure you could surmise.)
event.value = Math.abs(a) + b
var a = (35 - this.getField("Age").value)
if (a = -integer) { var b = 'BBY' } else if (a = +integer) { var b = 'ABY' } else if (a = 0) { var b = 'BBY' }
I've never used JavaScript before, so I assume am making some kind of very basic mistake. The calculation doesn't run consistently, and it never seems to allow the text field to be left empty. The math seems to get wonkier with each attempt. Is there a way to have it "reset" with each input change?
Any help would be appreciated. I'm way out of my depth.
