2014-03-19 42 views
0

我有Chrome開發者工具的代碼,如何從JavaScript對象

oListItem.get_item('Fruits'): Array[1] 
0: SP.FieldLookupValue 
$1E_1: 2 
$2d_1: "Big Round Apples;#Small Round Apples;" 
__proto__: Object 
length: 1 
__proto__: Array[0] 

我怎樣才能得到文本Big Round Apples;#Small Round Apples;

目前

使用此代碼,得到這個

oListItem.get_item('Fruits').val(); 

我得到Object object

回答

1

多個SP.LookupField值表示爲陣列SP.FieldLookupValue

//Get Multiple Lookup Field value 
var fruitValues = item.get_item('Fruits'); 
for(var i = 0; i < fruitValues.length; i++) { 
    var fruitValue = fruitValues[i]; 
    var fruitLabel = fruitValue.get_lookupValue(); 
    var fruitId = fruitValue.get_lookupId(); 
}