Skip to main content
January 19, 2017
Question

Adobe Acrobat Pro 7 - Fillable Forms - Java Script for List Options.

  • January 19, 2017
  • 2 replies
  • 358 views

Example:

1. Please Select each applicable option:

Option 1

Option 2

Option 3

Option 4

Option 5

Option 6

2 By holding the CTL key the user selects:

Option 1

Option 2

Option 3

Option 4

Option 5

Option 6

Printed/Saved output appears as:

Option 2, Option 4, Option 5.

Can anyone give me the Adobe Javascript to make this happen?

Thanks in advance!!!!

[Moved from the non-specific Coding Corner to a product-specific forum - moderator]

This topic has been closed for replies.

2 replies

Inspiring
February 11, 2017

Have you looked at the freely available Acrobat JavaScript Reference?

A combo box can be set to allow multiple or a single selection. One then needs to test the value of the field to see if it is an array or a single item. You can test the type of the value of the combo box to see if it is "string" for a single answer or "object" for multiple selections in an array;

Assuming a combo box field with a name of "Combo Box1" and text field for the result with a name of "Text1", a possible custom calculation script could be:

event.value = "";

// get combo box field object;

var oCombo = this.getField("List Box1");

// test value of combo box;

if(typeof oCombo.value  == "object")

{

var aValues = new Array();

for(var i = 0; i < oCombo.value.length; i++)

{

  if(oCombo.value != " " || oCombo.value != "")

  {

   // eliminate single space or null string selections;

   aValues[aValues.length] = oCombo.value;

  }

}

event.value = aValues.join(",");

} else {

if(oCombo.value != " " || oCombo.value != "")

{

  // eliminate space or null sting seledtions;

  event.value = oCombo.value;

}

}

try67
Community Expert
Community Expert
February 10, 2017

Acrobat-specific JavaScript questions should be asked here: JavaScript