Copy link to clipboard
Copied
I have a button labeled Military. When a user clicks on that button, I have a window that pops up asking if they're Active Duty, National Guard, or Reservist. I'm asking them to input a number representing one of the three choices and then another field auto-fills their choice when they click OK. Otherwise the field is blank. Here is what I have so far, but nothing is auto-filled into the other field:
var vMil = this.getField("13: Persona");
// Display Response Box
var vMilInfo = app.response("Input the number representing your military status.\n\n1) Active Duty\n2) National Guard\n3) Reservist"," [Box 9 - DESIGNATION OF PERSON]");switch(vMilInfo){
case "1":
vMil.value = "A = Active Duty";
vValidResponse = 1;
break;
case "2":
vMil.value = "N = National Guard";
vValidResponse = 1;
break;
case "3":
vMil.value = "V = Reservist";
vValidResponse = 1;
break;
vMil.value = "";
}
I'm doing this in Adobe Acrobat PDF form.
Copy link to clipboard
Copied
I have a button labeled Military. When a user clicks on that button, I have a window that pops up asking if they're Active Duty, National Guard, or Reservist. I'm asking them to input a number representing one of the three choices and then another field auto-fills their choice when they click OK. Otherwise the field is blank. Here is what I have so far, but nothing is auto-filled into the other field:
var vMil = this.getField("13: Persona");
// Display Response Box
var vMilInfo = app.response("Input the number representing your military status.\n\n1) Active Duty\n2) National Guard\n3) Reservist"," [Box 9 - DESIGNATION OF PERSON]");switch(vMilInfo){
case "1":
vMil.value = "A = Active Duty";
vValidResponse = 1;
break;
case "2":
vMil.value = "N = National Guard";
vValidResponse = 1;
break;
case "3":
vMil.value = "V = Reservist";
vValidResponse = 1;
break;
vMil.value = "";
}
I'm doing this in Adobe Acrobat PDF form.
Copy link to clipboard
Copied
Why did you add the last line where you're setting the vMil field to an empty string?
Also, why are you changing the value of vValidResponse in each case?
Copy link to clipboard
Copied
I added the last line because I thought that I was saying there that if the button is not checked, then the other field would be blank. As for the vValidResponse, I was testing something and just forgot to take those lines out before copying my code here.
Copy link to clipboard
Copied
You should put that line before the switch command, or under the "default" case.
Copy link to clipboard
Copied
Ok, I moved that line "vMil.value = ""; before the switch command and removed the "vValidResponse" command but it still won't auto-fill in the other field. I want the user to input a 1, 2, or 3 in the window and when they click OK, the other field will auto-fill either A = Active Duty, N = National Guard, or V = Reservist.
I forgot to mention that I'm still a beginner to JS...but you probably guessed that, I'm sure.
Copy link to clipboard
Copied
Check the JS Console (Ctrl+J) for error messages. If there are none, would you be able to share the file (via Dropbox, Google Drive, etc.)?
Copy link to clipboard
Copied
I got it to work. The text field had some JS in the Custom Calculation Script window.
Copy link to clipboard
Copied
Yeah, that might lead to a conflict. Glad to hear you get it to work!