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

Multi Line Text box calculation

New Here ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

Hi Guys,

Thanks for your help firstly. I have almost finished my pdf but have one last step.

On the first part of the .pdf there is a bunch of yes/no questions. These are coded for colours and to give a final risk rating depending on the answers.

I'd like to script a box on the last page that is a summary of must do risk controls, however I am having trouble with making it multiline.

Essentially, I'd like it to be something like.

if(this.getField("OCTA").value == "No") {

  event.value = "Radio carriage required, monitor ATC freq 15 mins prior to flight."

} else {event.value = "Nil"}

then add another line

if(this.getField("Non_CTRL_AD").value == "No") {

    event.value = "Radio carriage required, monitor FIA and CTAF 15 mins prior to flight."

} else {event.value = "Nil"}

I'm obviously doing something wrong here as it only calculates the first one. I'm obviously a noob at Javascript but am so close to finishing the form.

There are three or four of these questions that would give an additional risk control. And I just want them listed if the answer on the first page dropdown is a 'No'.

Any help?

TOPICS
Acrobat SDK and JavaScript

Views

423

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
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 28, 2017 Jul 28, 2017

Do it like this:

var lines = [];

if (this.getField("OCTA").value == "No") {

  lines.push("Radio carriage required, monitor ATC freq 15 mins prior to flight.");

}

if (this.getField("Non_CTRL_AD").value == "No") {

    lines.push("Radio carriage required, monitor FIA and CTAF 15 mins prior to flight.");

}

// etc.

if (lines.length==0) event.value = "Nil";

else event.value = lines.join("\n");

Votes

Translate

Translate
Community Expert ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

Do it like this:

var lines = [];

if (this.getField("OCTA").value == "No") {

  lines.push("Radio carriage required, monitor ATC freq 15 mins prior to flight.");

}

if (this.getField("Non_CTRL_AD").value == "No") {

    lines.push("Radio carriage required, monitor FIA and CTAF 15 mins prior to flight.");

}

// etc.

if (lines.length==0) event.value = "Nil";

else event.value = lines.join("\n");

Votes

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
community guidelines
Community Expert ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

LATEST

When you want add lines then use something like this:

event.value = event.value + "\n" + "  text  ";

Votes

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
community guidelines