Populating a text field with multiple drop down boxes

Im trying to let the user select multiple choices and with those construct a sentence. I have multiple drop down boxes. The user can only select one option from that drop down box and that option goes into the text field and so on. With those options the user can make a full text sentence in the text field. The problem is that every time i select more than one option the previous one dissapears. Im a beginner, so any help is appreciated. Thanks in advance.

Luis Mejia

6 Answers

Voted Best Answer

No wonder none of the suggestions works. We are not looking at a PDF form; we are looking at an XFA form, created with LiveCycle Designer.

You might look around in the XFA/LiveCycle Designer JavaScript documentation to see how fields and their values are addressed.

The concept on what to do is the same; you will simply need the appropriate syntax.

Hope this can help.

Max Wyss.

By Max Wyss   

Which field type are you actually using for the drop down box? Combo box or List box?

Only List box allows for multiple selections, and only if you have that feature enabled in the Options tab of the field property dialog.

So, if you have List boxes, deactivate that option.

Now, if you have combo boxes, I am not sure what you mean with "multiple options". Do you mean a selection from the various drop downs?

A quick and dirty script for assembling the text in the text field would be as follows:

We assume that the combo boxes are named seclectbox_n where n is the ordinal number of the field (if you have 5 selection fields, n would be 1, 2, 3, 4, and 5).

In the Calculate event of the field where you assemble the text, you would have the following script:

var mytext = "" ;
for (var i = 1 ; i < 6 ; i++) {
mytext += (this.getField("selectbox_" + i).value + " ") ;
event.value = mytext ;

And this should get your pieces together.

Hope this can help.

Max Wyss   

If you are using a list-box with multiple selection ticked, you can use something like this as the custom calculation event of your text field:

var listSelection = getField("List Box1").value;
if (typeof listSelection == "string") {
event.value = "Selected value is: " + listSelection;
} else if (typeof listSelection == "object") {
event.value = "Selected values are: " + listSelection.toString();

Gilad D (try67)   

Thank you for your responses. The objetive is using Drop down list boxes and with text choices assemble a text.
For example
Drop down list Box 1 choices: 1. Enter, 2. Exit, 3. Eject.
Drop down list Box 2 choices: 1. here, 2. there, 3. Plane.

The user can assemble a sentence in a text box for example:
(1)enter (3) plane
(2)exit (1) here

I have done that with macros in word but I prefer using Acrobat because of the other functions.

I have tried your suggestions but cant make something like the examples.

Thanks in advance.

Luis Mejia   

Gilad, when I use the debugger this is the error it shows:

this.getField is not a function1:XFA:form1[0]:#subform[0]:TextField1[0]:calculate

Luis Mejia   

Using the code from Gilad D for acrobat and after the guidance from Max Wyss I was able to resolve this problem:

This is the code to do that in Lifecycle. I hope it helps:

text.rawValue = Box1.rawValue + " " + Box2.rawValue;

text (name of the text box)
Box1 (name of the dropdown box 1)
Box2 (name of the dropdown box 2)

Thank you all for your guidance and help

Luis Mejia   

Please specify a reason: