trouble with an if/then statement script
hello, i am new to acrobat javascript but have been managing pretty well following forum advice i have found for each topic i have come across until now. I am trying to populate a field with an if/then statement. I have employee names that I want to be populated into a certain field when the adjacent field has the 4 digit employee number entered into it. I found an old thread but no matter what I tried, i can not get the script to work. Here is what I have so far. For reference, Emp.0 is the employee number field and NameRow.0 is the employee name field. I have the following formula plugged in to the custom calculation script of the NameRow.0 field. Employee numbers range from 0190 to 7xxx so i didnt know if have a leading zero in the employee number is throwing anything off either for the first two i was trying to get to work.
var v1 = +getField("Emp.0").value;
if (v1 === 0190) event.value = "jane doe";
if (v1 === 0210) event.value = "john smith";
I have also tried this formula but had it pasted into the NameRow.0 calculation script.
var v1 = +event.value;
var f2 = getField("NameRow.0");
if (v1 === 0190) f2.value = "jane doe";
if (v1 === 0210) f2.value = "john smith"
I am also hoping that when no employee number is listed or one is removed, the name field will return or stay empty.
Thanks,
Adam
