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

index of the selected item in drop down list

ashish
Registered: Mar 5 2007
Posts: 2

I am creating a form with some drop down list. On the selection of any item in the drop down list I need to find out the index of the item selected. e.g. if "item1", "item2", "item3" are the items in the drop down list and if i select "item2" then the script should be able to return 2. Is there any way to achieve this?
I am using designer 7.1 to desing the form

My Product Information:
Acrobat Pro 7.0.5, Windows
tedpadova
ExpertTeam
Registered: Dec 31 2005
Posts: 848
Yes. Your result fields will need to be scripted using JavaScripts. You'll have to review the JavaScript Specification Manual to learn more on JavaScript. Also, take a look at the FormCalc manual installed with Designer and some of the sample files you have on your hard disk also installed with Designer.

ted

The author of numerous books on Acrobat, Photoshop, Illustrator and the Adobe Creative Suite, and an international speaker on Adobe Acrobat, Ted Padova is a well-known PDF guru.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unforturnately LiveCycle List Fields don't have a property like "SelectedIndex". The list of items is a subnode of the field and you have to acquire and walk the list to find out the index of the result.

There is an easier way. Each item on list field can also have an export (or Bound) value. When you create the field in Deisgner, Check the "Specify Item Values" on the Object Binding tab. It should automatically set up index values. Now the "rawValue" of the field will the be index. To get the text, use the fields "fomattedValue" property.

var listIndex = MyField.rawValue;
var listText = MyField.formattedValue;

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

johnmolina
Registered: Mar 27 2008
Posts: 76
I am getting a message

Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

missing ; before statement
1:XFA:MAT100[0]:P1[0]:supplier[0]:change
************************
here is my code:

MAT100.P1.supplier::change - (JavaScript, client)

var prodr_supp_cd.rawValue = supplier.rawValue;
var supplier.value = supplier.formattedValue;
*********************************

what I am doing is selecting a name off a drop down list (supplier)
I want to take the index data (rawValue) and populate a field (prodr_supp_cd.rawvalue)

I have asked several people here that have done some with javascript and no one has been able to help much.

Any suggesstions are greatly appreciated.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
It appears you are using "::" where a ".' might work.

George Kaiser