Expand my Community achievements bar.

How do I auto fill a Text Box when a Check Box is selected?


Level 1

I have 4 check boxes that I would like to auto fill a text box if they are selected.

I am wondering how to do this (as I have never used a script before) and what script should be used?

I am new... so please forgive me as I learn the ropes.

5 Replies


Level 1

Have you considered a drop-down menu versus this option?

If the check boxes represent a choice from one question then a drop-down would work.

If the check boxes represent different choice, then they can be independent of each other.

Could you elaborate for better chance of answering your question?


Level 1

Thank you for your willingness to help.

The problem with a drop down is that it would not present all options when printed, and some of our users will be completing this form manually (printed). All options need to be displayed.

Here's an example:





They can check one of the above and then based on what they select, I want the next box (a text field) to pre-fill with their selection.

So if they select A12, the text box would automatically fill with A12.


Level 10

I the change:Event of the drop down box add:

Textfield1.rawValue = xfa.event.newText;


Level 1

Thanks for the reply... but per above I am NOT using a drop down.


Level 7


This is not too difficult.


if (this.rawValue == "1") {

  this.resolveNode("TextField1").rawValue = "A12";



if (this.rawValue == "1") {

  this.resolveNode("TextField1").rawValue = "B12";



For this purpose, i would consider radio buttons unless your intention is to be able to have multiple items selected. The main problem with checkboxes is that, what do you want to do when they are unchecked? The code above handles when the checkbox is checked but does nothing when unchecked. You would have a situation where you could check multiple boxes but the last one checked would send the value to the textfield.

To handle the uncheck add:

if (this.rawValue == "0") {

  this.resolveNode("TextField1").rawValue = null;


This will remove the value from the textfield when the box is unchecked.