Skip to main content
Known Participant
October 18, 2023
Question

IF THEN Statement for Performance Evaluation Form

  • October 18, 2023
  • 2 replies
  • 1148 views

I am trying to add an IF, THEN statement for my performance evaluation form. Basically what I need to happen is that if an "X" is place in any of the 5 columns (i.e., poor, good, great, better, best, each worth a number of 1-5 respectively), then in the score column it will reflect a number between 1-5. So if there is an "X" in the Poor column, the Score should equal 1; If there is an "X" in the Good column, the Score should equal 2 etc.

 

I wrote the following but so far, only the last line works:

 

var A = this.getField("ConsistentlyBelow1").value

var B = this.getField("BelowExpectations1").value

var C = this.getField("MeetsExpectations1").value

var D = this.getField("ExceedsExpectations1").value

var E = this.getField("ConsistentlyExceeds1").value;

if(A=="X") event.value=((1))

if(B=="X") event.value=((2))

if(C=="X") event.value=((3))

if(D=="X") event.value=((4))

if(E=="X") event.value=((5));

else event.value=0

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
October 18, 2023

The if statements need to be linked using "else if". 

You can read about it here:

https://www.pdfscripting.com/public/How-to-write-an-If-statement.cfm 

 

Here's the modified code

var A = this.getField("ConsistentlyBelow1").value
var B = this.getField("BelowExpectations1").value
var C = this.getField("MeetsExpectations1").value
var D = this.getField("ExceedsExpectations1").value
var E = this.getField("ConsistentlyExceeds1").value;

if(A=="X") event.value=1;
else if(B=="X") event.value=2;
else if(C=="X") event.value=3;
else if(D=="X") event.value=4;
else if(E=="X") event.value=5;
else event.value=0;

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
October 18, 2023

Thanks so much for responding!

I looks like the sames numbers are popping up in each column. I'm looking to have the corresponding value from the scale above to reflect in the Score Rate box (see screen shot), and the other boxes remain blank.

 

 

Known Participant
October 18, 2023

@Thom Parker thank you for responding and helping me out with this. The formula worked however it is populating the same number in all the columns. Is it possible to have a formula reflect the value in the Score column that corresponds with the scale when an "X" (or a check box) is selected?

 

 

Known Participant
October 18, 2023

Here is the performance evaluation form I am using. Essentially if any of these boxes are checked, I'd like for the value to equal 1,2,3,4 or 5 in the score column, as it will correspond to the box checked. 

Known Participant
October 18, 2023

@Thom Parker can you help me solve this?