Skip to main content
Participant
July 28, 2017
Answered

Multi Line Text box calculation

  • July 28, 2017
  • 2 replies
  • 661 views

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?

This topic has been closed for replies.
Correct answer try67

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

2 replies

Bernd Alheit
Community Expert
Community Expert
July 28, 2017

When you want add lines then use something like this:

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

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 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");