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

Checkbox/radio button to display text

Explorer ,
Sep 07, 2023 Sep 07, 2023

I have a variety of check boxes and radio buttons that I need to display text in a separate text box.  The check boxes are working up to the point of the radio buttons, but the radio buttons and any check boxes after the radio buttons are not.  They also need to be in a specific order, where I have a group of check boxes, followed by radio buttons, followed by check boxes.  This is what I currently have as calculated script, the red portion is my problem spot:

 

event.value = "";

var v1 = this.getField("Check Box1").value;

if(v1 != "Off"){

event.value += "Rec'd ";

}

var v2 = this.getField("Check Box2").value;

if(v2 != "Off"){

event.value += "adoption decree, ";

}

var v3 = this.getField("Check Box3").value;

if(v3 != "Off"){

event.value += "BC, ";

}

var v4 = this.getField("Check Box4").value;

if(v4 != "Off"){

event.value += "COA request, ";

}

var v5 = this.getField("Check Box5").value;

if(v5 != "Off"){

event.value += "COB doc, ";

}

var v6 = this.getField("Check Box6").value;

if(v6 != "Off"){

event.value += "Court Order, ";

}

var v7 = this.getField("Check Box7").value;

if(v7 != "Off"){

event.value += "DC, ";

}

var v8 = this.getField("Check Box8").value;

if(v8 != "Off"){

event.value += "DD, ";

}

var v9 = this.getField("Check Box9").value;

if(v9 != "Off"){

event.value += "DP docs, ";

}

var v10 = this.getField("Check Box10").value;

if(v10 != "Off"){

event.value += "ID, ";

}

var v11 = this.getField("Check Box11").value;

if(v11 != "Off"){

event.value += "Kaiser EF, ";

}

var v12 = this.getField("Check Box12").value;

if(v12 != "Off"){

event.value += "MC, ";

}

var v13 = this.getField("Check Box13").value;

if(v13 != "Off"){

event.value += "med ID card, ";

}

var v14 = this.getField("Check Box14").value;

if(v14 != "Off"){

event.value += "QMCSO, ";

}

var v15 = this.getField("Check Box15").value;

if(v15 != "Off"){

event.value += "parenting plan, ";

}

var v16 = this.getField("Check Box16").value;

if(v16 != "Off"){

event.value += "PDF, ";

}

var v17 = this.getField("Check Box17").value;

if(v17 != "Off"){

event.value += "SSN card, ";

}

var v18 = this.getField("Check Box18").value;

if(v18 != "Off"){

event.value += "INSERT OTHER ITEM HERE, ";

}

var v19 = this.getField("Choice1").value;

if(v19 != "Off"){

event.value += "Updated ";

}

var v20 = this.getField("Check Box20").value;

if(v20 != "Off"){

event.value += "address, ";

}

var v21 = this.getField("Check Box21").value;

if(v21 != "Off"){

event.value += "dep info, ";

}

var v22 = this.getField("Check Box22").value;

if(v22 != "Off"){

event.value += "name, ";

}

TOPICS
How to , JavaScript , PDF forms
1.8K
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
1 ACCEPTED SOLUTION
Explorer ,
Sep 08, 2023 Sep 08, 2023
LATEST

Figured it out for myself...if anyone else is interested see below:

 

event.value = "";

var v18 = this.getField("Check Box18").value;

if(v18 != "Off"){

event.value += "INSERT OTHER ITEM HERE, ";

}

var v19 = this.getField("Group1").valueAsString;

if(v19 == "Choice1"){

event.value += "Updated ";

}

var v20 = this.getField("Check Box20").value;

if(v20 != "Off"){

event.value += "address, ";

}

var v21 = this.getField("Check Box21").value;

if(v21 != "Off"){

event.value += "dep info, ";

}

var v22 = this.getField("Check Box22").value;

if(v22 != "Off"){

event.value += "name, ";

}

var v23 = this.getField("Check Box23").value;

if(v23 != "Off"){

event.value += "part data, ";

}

var v24 = this.getField("Check Box24").value;

if(v24 != "Off"){

event.value += "INSERT OTHER ITEM HERE, ";

}

var v25 = this.getField("Group1").valueAsString;

if(v25 == "Choice2"){

event.value += "No updates needed. ";

}

View solution in original post

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 ,
Sep 07, 2023 Sep 07, 2023

Check the Javascript console for errors (ctrl-j) 

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
Explorer ,
Sep 07, 2023 Sep 07, 2023

I could absolutely do that, but not helpful as I have no idea how to use it or write code.

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 ,
Sep 07, 2023 Sep 07, 2023

You can't press ctrl-j? 

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
Explorer ,
Sep 07, 2023 Sep 07, 2023

Of course I can, I have no idea how to use the console or how to write code.

 

Screenshot 2023-09-07 104237.jpgexpand image

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 ,
Sep 07, 2023 Sep 07, 2023

Does you get any error message when you use the form.?

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 ,
Sep 07, 2023 Sep 07, 2023

TypeError: this.getField(...) is null
74:AcroForm:Completed Phone Note:Calculate

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 ,
Sep 07, 2023 Sep 07, 2023

May be that the field "Choice1" doesn't exists. 

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 ,
Sep 07, 2023 Sep 07, 2023

It does exist, it is a radio button.

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 ,
Sep 07, 2023 Sep 07, 2023

Is  "Choice1" the name of the radio button group? 

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 ,
Sep 07, 2023 Sep 07, 2023

The radio button group is "Group1" but I only want text to be generated when "Choice1" is toggled.  When they toggle "Choice2", I do not want any text generated.

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 ,
Sep 07, 2023 Sep 07, 2023

Test the value of the radio button group. 

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
Explorer ,
Sep 08, 2023 Sep 08, 2023

I don't know how to do that.

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
Explorer ,
Sep 08, 2023 Sep 08, 2023
LATEST

Figured it out for myself...if anyone else is interested see below:

 

event.value = "";

var v18 = this.getField("Check Box18").value;

if(v18 != "Off"){

event.value += "INSERT OTHER ITEM HERE, ";

}

var v19 = this.getField("Group1").valueAsString;

if(v19 == "Choice1"){

event.value += "Updated ";

}

var v20 = this.getField("Check Box20").value;

if(v20 != "Off"){

event.value += "address, ";

}

var v21 = this.getField("Check Box21").value;

if(v21 != "Off"){

event.value += "dep info, ";

}

var v22 = this.getField("Check Box22").value;

if(v22 != "Off"){

event.value += "name, ";

}

var v23 = this.getField("Check Box23").value;

if(v23 != "Off"){

event.value += "part data, ";

}

var v24 = this.getField("Check Box24").value;

if(v24 != "Off"){

event.value += "INSERT OTHER ITEM HERE, ";

}

var v25 = this.getField("Group1").valueAsString;

if(v25 == "Choice2"){

event.value += "No updates needed. ";

}

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