Help me with populating a drop down field depending another drop down field

Avatar

Avatar

orlandoc3327638

Avatar

orlandoc3327638

orlandoc3327638

01-07-2019

Goog afternoon everybody, help me with this please.

I have three drop-down lists, and each drop-down list depends on another drop-down list, when I click the second drop-down list, and then click the first drop-down list, the content of the first drop-down list is repeated each time I click the second drop-down list. Please help to resolve this situation, perhaps i may send the pdf form to somebody.

Sincerely

orlando

first_clic.jpg

content_first_clic.jpg

second_clic.jpg

content_second_clic.jpg

third_clic.jpg

content_third_clic.jpg

and so on ...

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

01-07-2019

Hi,

Sounds like you need a {DropDownList1}.clearItems(); somewhere in your code before you start adding the new items.

If that doesn't help then add your code to the thread, or maybe a link to your form.

Regards

Bruce

Answers (8)

Answers (8)

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

04-07-2019

Hi,

I meant that if you changed the form variable to the format like;

,SECRETARIA MUNICIPAL DE PLANIFICACION Y DESARROLLO TERRITORIAL,SECRETARIA MUNICIPAL DE FINANZAS Y ADMINISTRACION

That is a CSV list, then code would only need to be

this.setItems(Secretarias.value);

Just, seemed a bit neater

Bruce

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

02-07-2019

Have a look at this sample;

https://sites.google.com/site/livecycledesignercookbooks/home/Catastro_unprotected_updated.pdf?attre...

I've moved the code to the preOpen and used the setItems method, if you don't need the values from the form variables in an array for something else, then you might want to change them to a csv format and then you could remove the call the the eval() function

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

02-07-2019

Hi,

Your file is password protected, so I haven't had a look.  But I would look at moving the code to populate the drop down item list into the preOpen event of the drop down, which is what it is for.  I would guess the enter event is being called more often than you expect.

Also, from Reader 9.0 there is a setItems() method, so as long as your form fillers aren't using a rather old version then you can set all the items in one hit, like;

Currency.setItems("US Dollar,USD,Canadian Dollar,CAD,Euro,EUR,United Kingdom Pounds,GBP", 2)

If you still want me to have a look can you take the password off.

Bruce

Avatar

Avatar

orlandoc3327638

Avatar

orlandoc3327638

orlandoc3327638

05-07-2019

Hi, Bruce thanks a lot

Avatar

Avatar

orlandoc3327638

Avatar

orlandoc3327638

orlandoc3327638

03-07-2019

Bruce, by the way, now the pdf form works perfectly, thanks a lot.

Avatar

Avatar

orlandoc3327638

Avatar

orlandoc3327638

orlandoc3327638

03-07-2019

Hi Bruce, thanks so much for helping me, by the option you say, can you please tell me how to change to a csv format and modify the form

Avatar

Avatar

orlandoc3327638

Avatar

orlandoc3327638

orlandoc3327638

02-07-2019

Hi Bruce, I'm sorry I forgot to remove the password, this is de pdf form without password

https://mega.nz/#!KWonjQqB!_VzmNLCIfVMbnMyilQY-oBYlryd1My_SnhS1LtL7K2A

Thanks for your help

Avatar

Avatar

orlandoc3327638

Avatar

orlandoc3327638

orlandoc3327638

01-07-2019

Hi Bruce, thanks for answering,

The link for the file is https://mega.nz/#!qDYQAKoY!jj7s-yK8VePAkZX5_AsXB7KYXrP-dZh6sMIQbqFQIxA

this is the enter event code for the first drop-down:

if (this.rawValue == null)

{var arrayItems = eval(Secretarias.value);for (var i=0; i < arrayItems.length; i++)

{this.addItem(arrayItems[i]);}}

and this code for the change event:

Direcciones_.rawValue = null;Direcciones_.clearItems();Direcciones_.setItemState(0, true);

Unidades_.rawValue = null;Unidades_.clearItems();Unidades_.setItemState(0, true);

this is the enter event code for the second drop-down:

if (Secretarias_.rawValue == "SECRETARIA MUNICIPAL DE PLANIFICACION Y DESARROLLO TERRITORIAL" && this.rawValue == null)

    {var arrayItems = eval(Direccion_1.value);for (var i=0; i < arrayItems.length; i++)

    {this.addItem(arrayItems[i]);this.setItemState(0,1);}}

if (Secretarias_.rawValue == "SECRETARIA MUNICIPAL DE FINANZAS Y ADMINISTRACION" && this.rawValue == null)

    {var arrayItems = eval(Direccion_2.value);for (var i=0; i < arrayItems.length; i++)

    {this.addItem(arrayItems[i]);this.setItemState(0,1);}}

and this code for the change event:

Unidades_.rawValue = null;Unidades.clearItems();Unidades_.setItemState(0, true);

for the third drop-down the code for the enter event is:

if (Direcciones_.rawValue == "DIRECCION DE GESTION URBANA Y TERRITORIAL" && this.rawValue == null)

{var arrayItems = eval(Unidad_1.value);for (var i=0; i < arrayItems.length; i++)

{this.addItem(arrayItems[i]);this.setItemState(0,1);}}

if (Direcciones_.rawValue == "DIRECCION DE INGRESOS Y SERVICIOS MUNICIPALES" && this.rawValue == null)

{var arrayItems = eval(Unidad_2.value);for (var i=0; i < arrayItems.length; i++)

{this.addItem(arrayItems[i]);this.setItemState(0,1);}}

Also in the Form Properties made five variables:

Secretarias.png

Direccion_1.png

Direccion_2.png

Unidad_1.png

Unidad_2.png

Thanks for your help