Multi Line Text box calculation

New Here ,
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?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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");

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

189

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

Multi Line Text box calculation

New Here ,
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?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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");

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

190

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
Jul 28, 2017 0
Most Valuable Participant ,
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");

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...
Jul 28, 2017 0
Adobe Community Professional ,
Jul 28, 2017

Copy link to clipboard

Copied

When you want add lines then use something like this:

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

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...
Jul 28, 2017 0