Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Specify dropdown to be readonly based on value populated?

Avatar

Former Community Member

Hi,

A pdf form has a dropdown field. The value is populated using a java program. The value can be anything. The dropdown should be readonly if the value populated is in the dropdown list else the user can select the value from dropdown list. How do I achieve this? Any help is greatly appreciated. Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Try this:

var vItems = this.length;

for (var i=0; i<vItems; i++) {

          if (this.rawValue == this.getDisplayItem(i)) {

                    this.access = "readOnly";

          }

}

Niall

View solution in original post

8 Replies

Avatar

Level 10

Hi,

I would generally use the exit event for something like this, but as the dropdon is populated from an external source you will need to use a different event. The change event may work, but I suspect that you may need to use the layout:ready event.

Something like this in JavaScript:

if (this.rawValue == "Yes") {

     this.access = "readOnly";

}

else

{

     this.access = "open";

}

Hope that helps,

Niall

Avatar

Former Community Member

Hi,

How to check if the value is in the list of values for the dropdown? The code you have provided validates for a particular value but need to validate if that value is in the list. Thanks

Avatar

Correct answer by
Level 10

Hi,

Try this:

var vItems = this.length;

for (var i=0; i<vItems; i++) {

          if (this.rawValue == this.getDisplayItem(i)) {

                    this.access = "readOnly";

          }

}

Niall

Avatar

Former Community Member

Hi,

It works like a charm. Is it possible to have a text and value for the dropdown list something like alias and will this code work in such a scenario? Also is it possible to share the list with other dropdown fields? Sorry if I am being very basic but I am very new to livecycle forms.

Avatar

Level 10

No problem!

Yes in LC Designer you can select a dropdown and in the Object > Field palette set the Item Values. This is what the user sees when they interact with the dropdown.

Next go to the Object > Binding palette and tick the Specify values. Then you can set the values for each Item in the dropdown. These values can be numeric or a text string, or both.

See example here: http://assure.ly/fYCuQ2.

And then some more advanced ones: http://assure.ly/jtTkdO, http://assure.ly/jcTahK, http://assure.ly/mP5Lud.

Good luck,

Niall

Avatar

Former Community Member

Hi,

I get 'The page cannot be found' error when I click on the links.

Avatar

Level 10

Hi,

At the weekend we changed over to a new web server and the IP is still percolating through the net. The site is up, so if you search the code solutions for dropdown, you should find the examples: http://assuredynamics.com/.

The URLs should be back within 24 hours.

Niall