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
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
Community Expert
December 29, 2017

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

Participating Frequently
January 2, 2018

PDF

Participant
July 19, 2023

how would it look if (Text3) was to be editable?

 

TIA

 


Thanks for you response. i am using Java Script for BlueBeam forms so i dont have the same Adobe windows shown in the example , i have been finding the scripts and copy paste ...

this is the script i am using

var v = this.getField("Group1").value;
if (v=="Choice1") event.value = "01";
else if (v=="Choice2") event.value = "012"; else if (v=="Choice3") event.value = "03";else if (v=="Choice4") event.value = "011";else if (v=="Choice5") event.value = "02";else if (v=="Choice6") event.value = "04";// etc.
else event.value = "";

i would like to add a (Choice7) that would allow the user to fill in the text box with anything thety would like.