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

How do you get the drop down item text instead of the value?

vwilliams
Registered: Feb 6 2008
Posts: 35
Answered

I'd like to show the drop down item text instead of the value in another text field, e.g. STATE. Below is my base code but the STATE field is rendering the value instead of the text. The code must work in Acrobat ver 6 and 7.

I tried .newText, nodeList.item, .item and rawValue but none of these are working. Does anyone know how to show the text and/or where I can find a list of all possible options, e.g. properties?

Thank you,
Valerie

// WORKING VERSION W/OUT ALERTS
// Concatenate Investigator Postal Address, i.e. City, State and Zip
// This shows the state w/ the value not the text

// Get field references
var xCITY = getField("Investigator.CITY");
var xSTATE = getField("Investigator.STATEID.STATELIST");
var xZIP = getField("Investigator.ZIP");
var xPostalAdd = getField("Investigator.PostalAdd");

if ((xCITY.value == "") & (xSTATE.value == "") & (xZIP.value == ""))
{
// Set this field value
xPostalAdd = "";

} else {

// Set this field value by concatenating the other fields
xPostalAdd.value = xCITY.value + ", " + xSTATE.value + " " + xZIP.value;

}

My Product Information:
Acrobat Standard 6.0.6, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Where exactly have you placed this code? Be aware that the logical AND operator is &&, not &, which is the bitwise AND operator in JavaScript.Also, some of the things you said you tried might apply to XFA forms created with LiveCycle Designer, but the code you posted would only work with forms created in Acrobat.

George
vwilliams
Registered: Feb 6 2008
Posts: 35
I'll updat the & to &&. I was Googling looking for an answer and those options were the only ones I could find.I'm creating a form in Acrobat 6 and the form will be used in ver 6 & 7.Valerie
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
In Acrobat Forms JavaScript you can use the "getItemAt()" method to get the export and item name from the options for a combo box or list box.

George Kaiser

vwilliams
Registered: Feb 6 2008
Posts: 35
I looked at/tried the "getItemAt()" but that is also pulling the value instead of the text. I'll search & work on it more tomorrow.
--Cheers, Valerie
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
It can pull both when the bExport value is properly set:

// Custom calculation script for "Investigator.PostalAdd"
// Get field references
var cCITY = this.getField("Investigator.CITY").value;
var oSTATE = this.getField("Investigator.STATEID.STATELIST");
var cZIP = this.getField("Investigator.ZIP").value;

// get combo box state item name
var cSTATEitemName = ""; // clear field
// loop through combo box for match to export value to item in combo box list
for (i = 0; i < oSTATE.numItems; i++) {
if(oSTATE.getItemAt(i, true) == oSTATE.value) {
cSTATEitemName = oSTATE.getItemAt(i, false); // get item name
break; // end loop on match
} // end if match
} // end for loop

// some debugging information
console.show();
console.clear();
console.println("oSTATE.value = " + oSTATE.value);
console.println("oSTATE item index = " + i);
console.println("oSTATE item name = " + oSTATE.getItemAt(i, false) );
// end debugging information

event.value = ""; // clear field
// fillin if all fields have a value
if ((cCITY != "") & (cSTATEitemName != " ") & (cZIP != "")) {
// Set this field value by concatenating the other fields
event.value = cCITY + ", " + cSTATEitemName + " " + cZIP;
}

George Kaiser

vwilliams
Registered: Feb 6 2008
Posts: 35
Thanks G. I wasn't using the getItemat correctly. I was able to tweek this a little so my other field was set instead of the drop down too.

Thanks again for your help. I will Accept your answer above and close this post.

Have a great day!
Valerie