Expand my Community achievements bar.

drop-down list formattedValue returning value, not text

Avatar

Level 4
Hi all,



I'm having a problem with a drop-down list. I can get the information I want in Reader 9, but we only have Reader 7.0.5 distributed at the moment.



I need to pull out its text value and its specified value, but everything I try just pulls out the specified value.



In Reader 9 formattedValue gives me the text and rawValue will give me the specified value.



Anyone able to help me please?



Thanks,



Tom
1 Reply

Avatar

Former Community Member
Tom:



It's possible, but complicated. You need to look into the field definition where we store the listbox contents. Then you can correlate the display item from the bound item. I've done this before in another context. I've appended the script I used.



John Brinkman

http://blogs.adobe.com/formfeed



function getDisplayValue(vField)

{

var vBoundItems = saveItems(vField);

var vDisplayItems = dispItems(vField);



if (vBoundItems == null || vDisplayItems == null)

return vField.rawValue;



for (var i=0; i<vBoundItems.length; i++)

{

if (vBoundItems.item(i).value == A.rawValue)

return vDisplayItems.item(i).value;

}

return "";

}

/*

* saveItems(vField)

* Get the list of items that are bound to the data

* @param vField -- the list field

*/

function saveItems(vField)

{

for (var i=0; i<vField.nodes.length; i++)

{

var vChild = vField.nodes.item(i);

if (vChild.className == "items" && vChild.save == "1")

return vChild.nodes;

}

return null;

}



/*

* dispItems(vField)

* Get the list of display items

* @param vField -- the list field

*/

function dispItems(vField)

{

/*

<items>

<text>aaa</text>

</items>

<items save="1" presence="hidden">

<text>111</text>

</items>

*/

for (var i=0; i<vField.nodes.length; i++)

{

var vChild = vField.nodes.item(i);

if (vChild.className == "items" && vChild.save != "1")

return vChild.nodes;

}

return null;

}