Expand my Community achievements bar.

SOLVED

Multiple Drop-down Lists with same content

Avatar

Level 2

Hello my friends, i have multiple drop-down lists that are the same in content, i have added them all to every drop-down list i have (30 pcs), but now the filesize is getting too big, so i'm wondering is there a way to make only 1 list and use that in all of my drop-down lists?

To specify: the list is only text-strings, nothing more. And also the list should be inside the forms (no external database)

Help much appreciated, thanx : =)

1 Accepted Solution

Avatar

Correct answer by
Level 6

Alrighty then. The forum won't let me upload files right now, so here's what to do using your example:

  1. In the form hierarchy, right-click on the "form1" object and select "Insert Script Object" from the menu.
  2. Rename the new script object to "Scripts".
  3. Paste the following code into the Scripts object (there won't be an event to select):

var ProductArray = new Array (

    "Product1 | 0127481 | 4 pcs | 1 | 27.10",

    "Product2 | 0127482 | 5 pcs | 2 | 28.20",

    "Product3 | 0127483 | 6 pcs | 3 | 29.30"

    );

function PopulateProductDropdown (ddlList)

{

    var numProducts = ProductArray.length;

    for ( var cnt = 0; cnt < numProducts; cnt++ )

        {

        ddlList.addItem(ProductArray[cnt]);

        }

}

 

  4. In each of the dropdown list object's Initialize event, paste the following code:

     form1.variables.Scripts.PopulateProductDropdown this);

 

That's it.  You won't need to add any list items to each of the dropdown list object, and you can remove the ones that are there for the first dropdown list.  Add any new products to ProductArray, following the syntax of the ones there.  Make sure you don't have a comma after the last one in the array.

View solution in original post

13 Replies

Avatar

Level 10

You can do this.

Keep your master drop-down with data and others with empty data.

On docReady event for the form, fill the other drop-down by reading the data from the master drop-down.

Make sense?

Nith

DISCLAIMER:

========================================================================

"This communication is intended only for the named recipient and others authorized to receive it.

It contains confidential or legally privileged information. If you are not the intended recipient, please notify us immediately, and note that any disclosure, copying, distribution or action you may take in reliance on this communication is strictly prohibited and may be unlawful. Unless indicated otherwise, this communication is not intended, nor should it be taken to create any legal and/or contractual relation or otherwise. Ministry of Finance (MOF) is neither liable for the proper and complete transmission of the communication, nor for any delay in its receipt.

Whilst MOF undertakes all reasonable efforts to screen outgoing e-mails for viruses, it cannot be held liable for any viruses transmitted by this e-mail."

Avatar

Level 2

Problem is that i don't know how to use/write docReady script?

Also i already have change*-event on the Drop-Down List.

Avatar

Level 10

Can you share your form with me to help you on this?

Nith

DISCLAIMER:

========================================================================

"This communication is intended only for the named recipient and others authorized to receive it.

It contains confidential or legally privileged information. If you are not the intended recipient, please notify us immediately, and note that any disclosure, copying, distribution or action you may take in reliance on this communication is strictly prohibited and may be unlawful. Unless indicated otherwise, this communication is not intended, nor should it be taken to create any legal and/or contractual relation or otherwise. Ministry of Finance (MOF) is neither liable for the proper and complete transmission of the communication, nor for any delay in its receipt.

Whilst MOF undertakes all reasonable efforts to screen outgoing e-mails for viruses, it cannot be held liable for any viruses transmitted by this e-mail."

Avatar

Level 2

Here is the attached testpage.

The change* javascript divides the textstring on the dropdownlist to 2 different fields (to the 1st and the 3rd)

Avatar

Level 6

Yes, but you might want to give us a clue about what your overall form will look like.  It looks like you'll want more rows like this, and in that case there is probably a better way to attack this than simply repeating the same code and fields over and over.  Using a table where you can define the row once, and then add as many instances as needed is cleaner.  Have you looked at the purchase order samples at http://help.adobe.com/en_US/livecycle/9.0/samples/lc_sample_selfpaced.html ?

Filling in multiple dropdown lists with the same data using a common script is not that complicated, and we can address that after you decide how to architect the rest of the form.

Avatar

Level 2

This is not a very complicated form, no outside databases etc.

Only thing I need is the 30 dropdown-lists to be filled with the same information, nothing more.

User selects the product from the drop-down list, the 1st and the 3rd fields are automatically copied from the drop-down list textString (selected value).

So, the architecture of the form is very basic.

Avatar

Correct answer by
Level 6

Alrighty then. The forum won't let me upload files right now, so here's what to do using your example:

  1. In the form hierarchy, right-click on the "form1" object and select "Insert Script Object" from the menu.
  2. Rename the new script object to "Scripts".
  3. Paste the following code into the Scripts object (there won't be an event to select):

var ProductArray = new Array (

    "Product1 | 0127481 | 4 pcs | 1 | 27.10",

    "Product2 | 0127482 | 5 pcs | 2 | 28.20",

    "Product3 | 0127483 | 6 pcs | 3 | 29.30"

    );

function PopulateProductDropdown (ddlList)

{

    var numProducts = ProductArray.length;

    for ( var cnt = 0; cnt < numProducts; cnt++ )

        {

        ddlList.addItem(ProductArray[cnt]);

        }

}

 

  4. In each of the dropdown list object's Initialize event, paste the following code:

     form1.variables.Scripts.PopulateProductDropdown this);

 

That's it.  You won't need to add any list items to each of the dropdown list object, and you can remove the ones that are there for the first dropdown list.  Add any new products to ProductArray, following the syntax of the ones there.  Make sure you don't have a comma after the last one in the array.

Avatar

Level 2

Can't get the code working, any way to send a samplefile?

Avatar

Level 6

Not yet; Adobe still has file uploads blocked, unless you send me a private message with an email address.

Avatar

Level 3

Can't get the code working either. I sure can use this. Can you email it tome?

dey2009@aol.com

Avatar

Level 2

Hello again, continuing the same project.

I got the file ready, but the filesize didn't drop, the size i pretty much the same as it would be when all of the dropdown-lists has been entered individually,

does anybody know how the filesize could be reduced?

Thank  : )