Hi shashidar,
To get the choice field values from client object model, please refer to:
Thanks,
Simon
- Marked as answer by Rock Wang MSFT Sunday, July 24, 2011 11:07 AM
OK I have two points to make on the marked answer.
- It points to an unofficial source.
- The code is just plain wrong. Have you tried it?
you can get the options of choice field usin below code..
//length of array---_all[0].Choices.results.length
$(document).ready(function() {
try {
jQuery.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "_api/web/lists/GetByTitle('listname')/fields?$filter=TypeDisplayName eq 'Choice'",
type: "GET",
async: false,
headers: { "Accept": "application/json;odata=verbose" },
dataType: "json",
success: function (data) {
_all = data.d.results;
fillchoices(_all);
//alert('yes');
//alert(_all[0].Id);
//option value for the first choice column
for(var f=0;f<_all[0].Choices.results.length;f++)
{
alert(_all[0].Choices.results[f]);
}
// if your list having more than one choice column then you can use _all[1].Choices.results[f] i.e. increase the _all array by 1 to move to the next choice field.
},
error: function (data) {
console.log(JSON.stringify(data));
alert('no');
}
});
}
catch (ex) {
console.log(ex.message);
}
});