Skip to main content
Participant
January 10, 2017
Answered

Check box to populate other field through calculation script

  • January 10, 2017
  • 2 replies
  • 660 views

Hello

I'm looking to have a section in my interactive form that is blank to begin with and if it is required the certain fields will be populated with text. My JS skills are basic but was able to put this together using another script I found - it doesn't work but hopefully sheds light on what I'm trying to achieve?

var selectedPrint_required = this.getField("Print_required").value;

if (selectedPrint_required=="") event.value = "-";

else if (selectedPrint_required=="Yes") event.value = "iPrint";

The "Print_required" field is a checkbox and when unchecked I'd like the current field to display "-" and when checked I'd like it to display "iPrint". I have 5 other fields that need to replicate this action using the same checkbox as the trigger. I also have a dropdown that I'd like blank when the trigger checkbox is unchecked but with one of the options chosen when checked. 

I hope this is possible. Thanks in advance for your help.

This topic has been closed for replies.
Correct answer JR Boulay

Hi.

Since the text field is automatically filled it don't need to be required, just set it as readonly to prevent edition.

Try this script placed in the checkbox (mouse up):

var oMyTextField = this.getField("TextField");

if (event.target.value != "Off") {oMyTextField.value = "iPrint";}

else  {oMyTextField.value = "-";}

(Replace TextField by its real name)

2 replies

JR Boulay
Community Expert
Community Expert
January 11, 2017

Don't forget to place the "-" as the default value in the text field, so it will be displayed after a reset.

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
January 11, 2017

Hi.

Since the text field is automatically filled it don't need to be required, just set it as readonly to prevent edition.

Try this script placed in the checkbox (mouse up):

var oMyTextField = this.getField("TextField");

if (event.target.value != "Off") {oMyTextField.value = "iPrint";}

else  {oMyTextField.value = "-";}

(Replace TextField by its real name)

Acrobate du PDF, InDesigner et Photoshopographe