开发者

how to add picklist value and text correctly using javascript?

I got and error while add picklist value : "The picklist value is out of the range."

myCode :

    var cityCodes = new Array();
cityCodes['1']='Adana - 322 ';
cityCodes['2']='Adiyaman - 416 ';
cityCodes['3']='Afyonkarahisar - 272 ';
cityCodes['4']='Agri - 472 ';
cityCodes['5']='Aksaray - 382 ';
cityCodes['6']='Amasy开发者_如何学Ca - 358 ';
cityCodes['7']='Ankara - 312 ';
cityCodes['8']='Antalya- 242 ';
cityCodes['9']='Ardahan- 478 ';

    for (var i in cityCodes) {
         crmForm.all.new_faxprefix.AddOption(cityCodes[i],i);
     }


Arrays are zero-index based, you started adding to your array at index 1, check out the following javascript code.

var cityCodes = [];
cityCodes[0]='Adana - 322 ';
cityCodes[1]='Adiyaman - 416 ';
cityCodes[2]='Afyonkarahisar - 272 ';
cityCodes[3]='Agri - 472 ';
cityCodes[4]='Aksaray - 382 ';
cityCodes[5]='Amasya - 358 ';
cityCodes[6]='Ankara - 312 ';
cityCodes[7]='Antalya- 242 ';
cityCodes[8]='Ardahan- 478 ';

for (var i = 0; i < cityCodes.length; i++) {
    crmForm.all.new_faxprefix.options[i] = new Option(cityCodes[i], i);
}

check out this fiddle


The Picklist values actually have to exist in the CRM customizations for the record to save. You can't just add them in script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜