Expand my Community achievements bar.

Initialize Drop List

Avatar

Level 2
I have a drop list that is being populated from a database. I also have a record in the database that holds a value (the hidden text value in the drop list) that could indicate which item in the droplist should be selected. Since the value in the database is not always up-to-date I want to initialize the drop list with this value, but allow the user to make an alternate selection if it is not correct. Is it possible to initialize a drop list?
2 Replies

Avatar

Level 5
Following FormCalc code may help you. rawValue porperty sets the default selection. For the following example 'Xyz' gets displayed after loading all the values. And user can change the selection form there. Hope this helps.

xfa.form.form1.Section41SF.DropDownList1.clearItems()xfa.form.form1.Section41SF.DropDownList1.addItem("Abc", 1)xfa.form.form1.Section41SF.DropDownList1.addItem("Xyz", 2)

xfa.form.form1.Section41SF.DropDownList1.addItem("Lmn", 3)



xfa.form.form1.Section41SF.DropDownList1.rawValue = 2



SekharN

www.lawson.com

Avatar

Former Community Member
I would simply bind the record which contains the initial selection of the drop down list to an invisible text field on your form and then add a line of script to the end of your drop down list's initialization script (which, I presume, is populating the list from the database) which sets the value of the drop down list to the value of this invisible text field (in JavaScript):



this.rawValue = InitialDropDownListSelection.rawValue;


Of course, this assumes that the InitialDropDownListSelection field's value is the same type of value which is assigned to each individual item in your drop down list.



I've attached a sample form (zipped along with a data file) which contains a drop down list initialized from records in an XML Data File. The default selection in this drop down list is based on the value of an invisible text field which is bound to a specific data node in the same XML Data File. While this isn't working from a data base, the principal is the same. If you open the form in Acrobat (instead of previewing it from Designer 7.1), remember to import the data into the form after you've opened it.



Stefan

Adobe Systems