Copy link to clipboard
Copied
Hello again Acrobat community!
I am creating a form for a client that utilizes radio buttons for various questions that are asked throughout the form, I have seven groups (Group1, Group2..... etc) with Yes and No selections. At the bottom of the form they would like a box which I have labeled severityScore that I would like to assign "Low Risk", "Moderate Risk" or "High Risk" text in the box as well as a yellow, orange, or red backround fill for the box. As an example if the user were to answer No to the first two questions, there would be no change to the severityScore text field and they would be done using the form. If they answer yes to question one the severityScore box would display Low Risk text and have backround of yellow and they would move on to question two, if they answered no to question two, Low RIsk with yellow backround would remain and they would be finished. If they answered Yes to question two they would move on to question three where if they answered No, Low Risk with yellow backround would remain but if they answered Yes then the severityScore textbox would go from populating Low Risk text and yellow backround to Moderate Risk text with orange backround. I guess what I am looking for is a jumping off point to get this started, as in, should I handle this by assigning values to the buttons and then totaling or what would be the smoothest way to proceed? Could someone provide a starting point for this? Thanks in advance!!!
Copy link to clipboard
Copied
Yes, you can add export values (Radio button choices) to the questions, for example set all "Yes" buttons choice to be 1.
Then you can use the script to loop over all groups and count the total of "Yes" choices and depend on that set value to "severityScore", something like this:
var score = 0;
for (var i=1; i<=7; i++){
var f = Number(this.getField("Group" + i).valueAsString);
if (f === 1)
score++;}
if (score == 0) {
event.value = "";
event.target.fillColor = color.transparent;}
else if (score > 0 && score <= 2) {
event.value = "Low Risk";
event.target.fillColor = color.yellow;}
else if (score > 2 && score <= 5) {
event.value = "Moderate Risk";
event.target.fillColor = ["RGB", 255 / 255, 136 / 255, 0 / 255];}
else if (score > 5 && score <= 7) {
event.value = "High Risk";
event.target.fillColor = color.red;}
I just used score as example to set value and change color, you change those values to what they should actually need to be.
Copy link to clipboard
Copied
Awesome, thank you for your time!!!