populate text field from several dropdown selections

New Here ,
Oct 08, 2017

Copy link to clipboard

Copied

I have created a from where by I make a selection from a dropdown list and it puts a sentence into a text field from the export value. I am using the following code in a custom format script that someone helped me with.

var f = event.target;

var pos = f.currentValueIndices; //position sélectionnée

this.getField("Speaking").value = f.getItemAt(pos, true);

I want the text field to be able to add a second or third line of text from a different dropdown menu. I this possible?

Currently the new selection will just overwrite the previous selection. Each dropdown menu has 5 options- limited, basic, sound, high, outstanding and I want a different sentence to insert for each selection.

On another post someone told me to do a custom calculation script for the textfield as follows:

var v1 = this.getField("Speaking").valueAsString;

var v2 = this.getField("Writing").valueAsString;

if (v1=="sound" && v2=="basic") event.value = "Speaking sound outcome\nWriting basic outcome";

But to do this I would have to write an if statement for each combination and in some areas of my document I have up to 5 dropdown menus feeding into the text field. Is there an easier way to do it? Thanks

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Use something like this:

var v1 = this.getField("Speaking").valueAsString;

var v2 = this.getField("Writing").valueAsString;

var val = "";

if (v1=="sound") {

  if (val.length > 0) val = val + "\n";

  val = val + "Speaking sound outcome";

}

if (v2=="basic") {

  if (val.length > 0) val = val + "\n";

  val = val + "Writing basic outcome";

}

event.value = val;

TOPICS
Acrobat SDK and JavaScript

Views

191

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

populate text field from several dropdown selections

New Here ,
Oct 08, 2017

Copy link to clipboard

Copied

I have created a from where by I make a selection from a dropdown list and it puts a sentence into a text field from the export value. I am using the following code in a custom format script that someone helped me with.

var f = event.target;

var pos = f.currentValueIndices; //position sélectionnée

this.getField("Speaking").value = f.getItemAt(pos, true);

I want the text field to be able to add a second or third line of text from a different dropdown menu. I this possible?

Currently the new selection will just overwrite the previous selection. Each dropdown menu has 5 options- limited, basic, sound, high, outstanding and I want a different sentence to insert for each selection.

On another post someone told me to do a custom calculation script for the textfield as follows:

var v1 = this.getField("Speaking").valueAsString;

var v2 = this.getField("Writing").valueAsString;

if (v1=="sound" && v2=="basic") event.value = "Speaking sound outcome\nWriting basic outcome";

But to do this I would have to write an if statement for each combination and in some areas of my document I have up to 5 dropdown menus feeding into the text field. Is there an easier way to do it? Thanks

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Use something like this:

var v1 = this.getField("Speaking").valueAsString;

var v2 = this.getField("Writing").valueAsString;

var val = "";

if (v1=="sound") {

  if (val.length > 0) val = val + "\n";

  val = val + "Speaking sound outcome";

}

if (v2=="basic") {

  if (val.length > 0) val = val + "\n";

  val = val + "Writing basic outcome";

}

event.value = val;

TOPICS
Acrobat SDK and JavaScript

Views

192

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
Oct 08, 2017 0
Adobe Community Professional ,
Oct 09, 2017

Copy link to clipboard

Copied

Use something like this:

var v1 = this.getField("Speaking").valueAsString;

var v2 = this.getField("Writing").valueAsString;

var val = "";

if (v1=="sound") {

  if (val.length > 0) val = val + "\n";

  val = val + "Speaking sound outcome";

}

if (v2=="basic") {

  if (val.length > 0) val = val + "\n";

  val = val + "Writing basic outcome";

}

event.value = val;

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...
Oct 09, 2017 0
New Here ,
Oct 09, 2017

Copy link to clipboard

Copied

Thank you so much. Worked perfectly!

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...
Oct 09, 2017 0