Check listbox if it's empty

Avatar

04-11-2008

Hey,



I allow to dynamically add items to a listbox then want to check if

it's empty. I want to know if there's something similar to:



if ((ac.rawValue == null) || (ac.rawValue == ""))

{ xfa.host.messageBox("Please fill out all the fields"); }



Thanks!

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

04-11-2008

Not sure what you are trying to do, but you can only add one item to the list and that becomes the selected item. So ListBoxName.rawValue will give you the value they selected. If they did not select anything then the value will be null....which means they did not add an entry either.

Avatar

04-11-2008

Thanks for your answer Paul.



Actually I have a form which has text fields, radio buttons and listboxes. At the end of the form I have a Print button which first checks the emtpy fields.



Everything is working great with the textfields (using the code listed above) but when trying to get checked the listbox value I can't do it using that code.



I want to know the best method in checking if a listbox has at least 1 element in it.



Same for the radio buttons - how can I check that at least one radio button has been selected.



Thanks!

Avatar

04-11-2008

Okay, it's working. Only if the user selects something in the listbox. For that matter - how can I select automatically always the first item in the listbox once something is dynamically added to the listbox?

Avatar

04-11-2008

Nevermind,.. found the answer here:

http://www.adobeforums.com/webx/.3c054091/0?14@@



//get the listbox's all the nodes

var nodeList = form1.page1.ListBox1.resolveNode("#items").nodes;

//set the listbox's value with the first item's value

form1.page1.ListBox1.rawValue = nodeList.item(0).value;



Hope it will help someone else in the future! Thread closed.