Skip to main content
Participating Frequently
December 29, 2017
Answered

Autofill text box based on radio button choice

  • December 29, 2017
  • 2 replies
  • 6913 views

We have tried a variety of methods and javascript and absolutely nothing will work. Ideas and help are greatly appreciated!

Here are two codes we tried with no luck:

var A = this.getfield("Group16").value;

var Y = this.getfield("Text21").value;

var Z = this.getfield("Text22").value;

if (A=="Choice1")

document.getElementById("Text27").value = Y;

else document.getElementById("Text27").value = Z;

document.getElementById("Text27").value=this.getElementById("Group16").value;

#2:

var S = this.getfield("Text21").value;

var T = this.getfield("Text26").value;

{

if(Group16.value=="Choice1"){

var S=this.getfield("Text21")

}

else{

var S=this.getfield("Text26")

}

}

This topic has been closed for replies.
Correct answer try67

It should not be editable. The value should be determined only by the radio-button.


OK. Then use this code as the custom calculation script of "Text3":

var a = this.getField("Group16").valueAsString;

var b = this.getField("Text1").valueAsString;

var c = this.getField("Text2").valueAsString;

if (a=="Choice 1") event.value = b;

else if (a=="Choice 2") event.value = c;

else event.value = "";

2 replies

Thom Parker
Community Expert
December 29, 2017

If this is for a PDF, then you'll need to learn a bit about PDF forms and the PDF JavaScript model.

See the videos posted here to get you started:

PDF Form Field Scripting Basics - YouTube

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
December 29, 2017

Is this code for a PDF file or an HTML file?

Participating Frequently
January 2, 2018

PDF

Participating Frequently
January 2, 2018

Should Text3 be editable by the user, or should its value be determined only by the radio-button (and other text field)?


It should not be editable. The value should be determined only by the radio-button.