Copy link to clipboard
Copied
Hello,
I am extremely new to PDF creation and I'm hoping to get some help. I'm creating a PDF of a rating scale where a subject is rated on different tasks in different domains. So far I have it figured out that once the rating scale number is input, it will calculate the raw domain score and the average domain score.
The part I'm stuck on is I'm trying to add a label then based on the average domain score. Below is the scale with labels, so for example if the calculated value is 1.33 I'd like the field to automatically put the label "Mild".
0.0-0.49 None
0.50-1.49 Mild
1.50-2.49 Moderate
2.50-3.49 Severe
3.50-4.0 Extreme
Is this something that can be accomplished in JavaScript? Any help would be greatly appreciated! Thank you for your time.
You can use this code as the custom Calculation script of the label text field:
var averageDomainScore = Number(this.getField("average domain score").valueAsString);
if (averageDomainScore<0.5) event.value = "None";
else if (averageDomainScore<1.5) event.value = "Mild";
else if (averageDomainScore<2.5) event.value = "Moderate";
else if (averageDomainScore<3.5) event.value = "Severe";
else if (averageDomainScore<=4) event.value = "Extreme";
else event.value = "";
Copy link to clipboard
Copied
You can use this code as the custom Calculation script of the label text field:
var averageDomainScore = Number(this.getField("average domain score").valueAsString);
if (averageDomainScore<0.5) event.value = "None";
else if (averageDomainScore<1.5) event.value = "Mild";
else if (averageDomainScore<2.5) event.value = "Moderate";
else if (averageDomainScore<3.5) event.value = "Severe";
else if (averageDomainScore<=4) event.value = "Extreme";
else event.value = "";
Copy link to clipboard
Copied
Thank you so much! That worked perfectly and did everything I wanted it to do.