These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to check if drop-down list is empty, i.e. no item has been chosen

Lea1337
Registered: Jul 14 2009
Posts: 64
Answered

I have developed a dynamic form that is filled with fields after a user makes choices from a couple of drop-down menus. What I would like to do, is to have a code that checks whether the user has made a choice in one of the drop-down menus. If not, an error message should be displayed and the form should not be filled with any fields.

I have tried the following:

if (form1.Main_subform.Caption_subform.LocationDDList.xfa.event.change == null)

and

if (form1.Main_subform.Caption_subform.LocationDDList.xfa.event.change == "")

but none of these seem to work. I'm not even sure if I should use the 'change' event in this case..? Does anyone know how I can check if a drop-down list is "empty"/no item is chosen?

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Use this code in the change or exit event:

if (form1.Main_subform.Caption_subform.LocationDDList.rawValue == null){...}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Lea1337
Registered: Jul 14 2009
Posts: 64
Thank you for a prompt reply, but unfortunately it did not work, neither did

if (form1.Main_subform.Caption_subform.LocationDDList.rawValue == "")

(Tried it just to eliminate possibilities). The messagebox that is supposed to appear if the condition in the if-sentence is true never shows, and nothing happens (no fields in the form are made visible).

I have placed this code in a function that is called from the change-event in another drop-down menu. I'm currently running a similar code from the same change-event, that checks if a choice is made in a radio button list (but instead of checking whether the radio button list is "empty", I reverse the procedure and check if the radio button chosen is NOT one of the possible radio button choices), which works fine. I also had problems finding out how to check if a radio button list was empty, that's why I reversed the code. But this is not as easily done in the drop down list, since I have many more possible choices there.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Option boxes, cobo or list, require a unique string entry for each option, and logically a 'no option' is and 'option'. You will have to enter at least one space and you can test for that value.

George Kaiser

Lea1337
Registered: Jul 14 2009
Posts: 64
Adding an "empty" choice worked, thanks! :-)