Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto Populate a Box off Radio Button

Community Beginner ,
Mar 19, 2019 Mar 19, 2019

I have 2 radio buttons i'm looking to determine other text boxes in my pdf.

If Group1 - Choice1 is selected I want to be able to populate N/A in the boxes and make them read only. If Group1 - Choice2 I want to make those fields (that would be read only with Choice 1) blank and fillable. Hopefully this makes sense.

TOPICS
PDF forms
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2019 Mar 19, 2019

What about if neither option is selected?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 19, 2019 Mar 19, 2019

Well for this document, one is going to have to be selected. It is for Auditing purposes, so if neither is selected the whole document is 100% wrong. It is also the first selection on the pdf file and the rest of the boxes will generate off the first selection.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2019 Mar 19, 2019

OK. You can use something like this as the MouseUp event of the radio-button fields, then:

var f = this.getField("Text1");

var v = event.target.value;

if (v=="Choice1") {

    f.value = "N/A";

    f.readonly = true;

} else {

    f.value = "";

    f.readonly = false;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 19, 2019 Mar 19, 2019

Thank you! I ended up having to change it a bit and run it in custom calculation script. This was my final that worked!

var f = this.getField("Text1");

var v = this.getField("Group1").value; if (v=="Choice1") { 

    f.value = "N/A"; 

    f.readonly = true; 

} else { 

    f.value = ""; 

    f.readonly = false; 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2019 Mar 19, 2019

This will overwrite any value you enter into the text field, though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 19, 2019 Mar 19, 2019

Okay so It needs to go in the mouse up? The code you gave me wasn't populating anything at all. I made some tweaks and got it to at least populate.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2019 Mar 19, 2019
LATEST

Is the text field actually called "Text1"? If not, you'll need to adjust the code, of course.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines