Select dynamic initialization

//CtrlId is a select control, arrText is an array of display content, arrValue content is the value of the array.
//Description: attention to the arrText and the length of the arrValue array need to be consistent.
function setSelectInfo(ctrlId, arrText, arrValue) {
var objCtrl = $('#' + ctrlId);
objCtrl.empty();
var iCount = arrText.length;
//alert(iCount);
var _optionStr = "";
for(var i=0; i <iCount; i++) {
_optionStr = "<option value=" + arrValue[i] + ">" + arrText[i] + "</option>";
objCtrl.append(_optionStr);
}
}

Text

Started by Evan at November 15, 2016 - 11:48 AM

For this is not necessary to use the JQ, the data format is generally [ {text:xxx,value} ]

Posted by Ann at November 26, 2016 - 12:31 PM

select.options.add(new Option("text","value"));

Posted by Colby at December 10, 2016 - 1:20 PM