Radio Button to change comments

New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

I am wanting to use one of three radio buttons to change comments in another section of the form. The form is for an elevation certificate and the radio button options are construction drawing, under construction, and finished construction. At each stage there are different things needed in the comments section that deal with the stages of the EC. Is there a way to link the comments in the comments section with the radio button choices so I don't have to type them in each time?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

OK, then you can use something like this as the custom calculation script of the comments text field:

var v = this.getField("form1[0].ec_Section_C_D[0].SectionC[0].C1[0].RadioButtonList[0]").valueAsString;

if (v=="1") event.value = "Text for construction drawing";

else if (v=="2") event.value = "Text for under construction";

else if (v=="3") event.value = "Text for finished construction";

else event.value = "";

TOPICS
Acrobat SDK and JavaScript

Views

133

Likes

Translate

Translate

Report

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

Radio Button to change comments

New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

I am wanting to use one of three radio buttons to change comments in another section of the form. The form is for an elevation certificate and the radio button options are construction drawing, under construction, and finished construction. At each stage there are different things needed in the comments section that deal with the stages of the EC. Is there a way to link the comments in the comments section with the radio button choices so I don't have to type them in each time?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

OK, then you can use something like this as the custom calculation script of the comments text field:

var v = this.getField("form1[0].ec_Section_C_D[0].SectionC[0].C1[0].RadioButtonList[0]").valueAsString;

if (v=="1") event.value = "Text for construction drawing";

else if (v=="2") event.value = "Text for under construction";

else if (v=="3") event.value = "Text for finished construction";

else event.value = "";

TOPICS
Acrobat SDK and JavaScript

Views

134

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 26, 2019 0
Adobe Community Professional ,
Apr 26, 2019

Copy link to clipboard

Copied

Yes, if by comments you mean markup annotations. Just about every aspect of an annotation can be changed with a script.

Here's the JavaScript reference entry for annotations.

Acrobat DC SDK Documentation

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

I think that you mean the value of a text field, not actual comments (ie, annotations).

If that's the case it's also possible, using a simple script. Please clarify what you mean, though.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

On the form there is a box in which I have to type various comments based on the status of the elevation certificate. What I would like to do is have that area filled out with the comments for each stage and only show what is needed for the radio button that is checked.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Adobe Community Professional ,
Apr 26, 2019

Copy link to clipboard

Copied

Do you have Acrobat Professional? If so, put the PDF into "Prepare Form" mode. This will allow you to see and edit both the Radio buttons and the "comment area" if it is in fact a text field.  In order to change this "comment area" with a script you need to know what kind of element it is and it's name.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

The current name for the comments section is form1[0].ec_Section_G[0].SectionG[0].comments[0]

here is the tooltip for the section Comments (including type of equipment and location, per C2(e), if applicable)

it appears to be a text field

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

This kind of name is usually used in LiveCycle Designer forms. Is this what you have, or is it a "regular" Acrobat form?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

It looks like a standard PDF from to me I have been Acrobat DC to edit it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

OK. What's the name of the radio-button group, and the values of each one of the choices in it?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Adobe Community Professional ,
Apr 26, 2019

Copy link to clipboard

Copied

This looks like a static LiveCycle form. But it could also be simple conversion from an LC form.

You need to make sure before attempting to make any edits.

Run this line of code in the Console window and tell us what is returns.

xfa

It's just this one word. It will tell you the type of form.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

ReferenceError: xfa is not defined

1:Console:Exec

undefined

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

It's an Acrobat form, then.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

The radio buttons are showing

form1[0].ec_Section_C_D[0].SectionC[0].C1[0].RadioButtonList[0]

Section C1 Radio Button Group

then under options the radio choice changes from 1 for construction drawing to 2 for the under construction and Finished construction

The form is a standard elevation certificate from FEMA that has been slowly modified to make it easier to deal with multiple homes and municipalities

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

OK, then you can use something like this as the custom calculation script of the comments text field:

var v = this.getField("form1[0].ec_Section_C_D[0].SectionC[0].C1[0].RadioButtonList[0]").valueAsString;

if (v=="1") event.value = "Text for construction drawing";

else if (v=="2") event.value = "Text for under construction";

else if (v=="3") event.value = "Text for finished construction";

else event.value = "";

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 30, 2019

Copy link to clipboard

Copied

Thank you that worked exactly as I needed. Now I just need to place the text on separate lines

var v = this.getField("form1[0].ec_Section_C_D[0].SectionC[0].C1[0].RadioButtonList[0]").valueAsString; 

if (v=="1") event.value = "C2.a,d +e) Proposed Elevation" +

"*Per LOMR 19-06-0138A Effective Date: 10/18/18" +

"500 Year BFE  = '" +

"Min FF = '"; 

else if (v=="2") event.value = "*Per LOMR 19-06-0138A Effective Date: 10/18/18" +

"500 Year BFE  = '" +

"Min FF = '"; 

else if (v=="3") event.value = "C2.e) AC Pad" +

"*Per LOMR 19-06-0138A Effective Date: 10/18/18" +

"500 Year BFE  = '"; 

else event.value = "";

so instead of C2.a,d +e) Proposed Elevation*Per LOMR 19-06-0138A Effective Date: 10/18/18500 Year BFE  = 'Min FF = ' when I use construction drawing I need

C2.a,d +e) Proposed Elevation

*Per LOMR 19-06-0138A Effective Date: 10/18/18

500 Year BFE  = '

Min FF = '

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 30, 2019 0
Most Valuable Participant ,
Apr 30, 2019

Copy link to clipboard

Copied

Insert "\n" into the strings at the spots where you want to add a line-break.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 30, 2019 0
New Here ,
Apr 30, 2019

Copy link to clipboard

Copied

thank you I just figured it out as you answered. Kind of feeling a little slow on that one.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 30, 2019 0