Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Clearing Drop-Down List Selection

Avatar

Former Community Member

I have a form developed in Adobe Livecycle that has numerous fields setup with Drop-Down lists.  Some of these lists are quite lengthy.  The simple issue I am trying to resolve is that at the moment if a user of the form selects an item from the Drop-Down list for a field (perhaps accidentally) they are unable to 'clear' that selection.  I would like them to be able to clear that field - essentially putting it back to blank (no entry).  Is there a way to do this or what is the best way to accommodate the need.  Thanks.

7 Replies

Avatar

Level 10

There are a couple of solutions. (1) include a display item " ". This will appear as a blank item on the dropdown list that the user can select. On exiting, it will appear as a blank selection. (2) check out this example that shows how you can use the Shift key with a click, to clear a field/selection: http://assure.ly/j1KdNq. Niall (I know the example is using radio buttons, but expand your mind)

Avatar

Former Community Member

Thanks for your reply/suggestions.  I really like the idea of the ctrl/click to clear.  I have put the code suggested into a change event for the field but it doesn't seem to work for me.  Perhaps I am doing something wrong.  From Livecycle I have selected the field and added an event ( 'change', 'javascript', 'client') with the following:

 

// if Control is held, clear selection

if (xfa.event.modifier)

{

xfa.event.change = "";

}

Upon saving and reenabling the form I am not able to clear the selection via ctrl click

Avatar

Level 10

Hi,

My experience is that the Control key (modifier) does not work in Apple Mac OS, but that it does in Windows.

Because of this I find the Shift key is a better option. 

// if Shift is held, clear selection

if (xfa.event.shift) {

     xfa.event.change = "";

}

Also users will be more familar with the Shift key, than the Control key.

Niall

Avatar

Former Community Member

Yes, I have tried both the control and shift key options.  Neither one seems to work for me for some reason.

Avatar

Level 10

Hmm, not sure what is going on. I have tested it here on both Windows and Mac OS and the Shift works in both environments.

Are you using Acrobat or Reader? Or are you using a third-party viewer?

Does the above example work for you?

Can you share your form? Or the part that is causing you trouble?

Niall

Avatar

Former Community Member

Strangely enough the following code works on a radio button within the form but not on a drop-down field.

// if Shift is held, clear selection

If (xfa.event.shift)

(

this.rawValue ="";

)

Avatar

Level 10

Hi,

Because you are using the change event, you should not try to set the object's rawValue. Instead the script is setting the change value of the dropdown and setting it to an empty string "".

I have tested this again here and it works for a dropdown in the change event:

// if Shift is held, clear selection

if (xfa.event.shift) {

     xfa.event.change = "";

}

The user has to hold Shift, while they are making a selection in the dropdown.

Note that I am using xfa.event.change = ""; and not this.rawValue = "";

In addition, you can use "" to clear a dropdown and a radio button exclusion group. But null will not work on a radio button exclusion group.

Niall