I'm trying to create a form that determines if a patient requires a particular lab based on their history. "field X" is the patient's age and "field Y" is another age. I'm trying to create a script that determines if "field Y" is plus or minus 10 years of the age in "field X". If it is within 10 years I want "field Z" to show. If the age isn't within 10 years, then I want "field Z" to remain hidden.
I'd appreciate any help with this. I'm almost done with this form and it's looking great so far. Thanks in advance!
Enter this code as the custom calculation script of "Z":
var x = this.getField("X").valueAsString; var y = this.getField("Y").valueAsString; if (x=="" || y=="") event.target.display = display.hidden; // if either field is empty, hide this field else event.target.display = (Math.abs(Number(x)-Number(y))<10) ? display.visible : display.hidden;
Thanks! This worked perfectly.