Skip to main content
Known Participant
Oct 18, 2023 12:20 AM UTC
Question

IF THEN Statement for Performance Evaluation Form

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 is closed to new replies. Start a new post to keep the conversation going.

9 replies

Thom Parker
Community Expert
Community Expert
Oct 18, 2023 6:08 AM UTC

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;

 

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
Oct 18, 2023 3:52 PM UTC

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.

 

 

Translate
Known Participant
Oct 18, 2023 3:54 PM UTC

@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?

 

 

Translate
Known Participant
Oct 18, 2023 12:23 AM UTC

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. 

Translate
Known Participant
Oct 18, 2023 12:24 AM UTC

@Thom Parker can you help me solve this?

Translate