84533871 2013-04-21
代码如下:
//绑定下拉框 //ctnSelector:下拉框ID,带#号, //jsonData:JSON数据, //txtField:文本字段名称, //valField:值字段名称, //strOptions:默认填加的项 function InitSelectOptions(ctnSelector, jsonData, txtField, valField, strOptions) { if ($(ctnSelector).length == 0) { return false; }; $(ctnSelector).html(''); var optList = strOptions; if (typeof (jsonData) != undefined) { for (var jitem in jsonData) { if (jitem == "insertAt" || jitem == "removeAt" || jitem == "moveTo") { continue; //解决flareJ.Base.js导致的问题。 } optList += "<option value='" + jsonData[jitem][valField] + "'>" + jsonData[jitem][txtField] + "</option>"; } } $(ctnSelector).html(optList); }
代码如下:
//绑定下拉框 //ctnSelector:下拉框ID,带#号, //jsonData:JSON数据, //txtField:文本字段名称, //valField:值字段名称, //strOptions:默认填加的项 function InitSelectOptions(ctnSelector, jsonData, txtField, valField, strOptions) { if ($(ctnSelector).length == 0) { return false; }; $(ctnSelector).empty(); var sel = $(ctnSelector).get(0); var newOpt = $(strOptions); var newOption1 = document.createElement("OPTION"); newOption1.text = newOpt.text(); newOption1.value = newOpt.val(); sel.options.add(newOption1); if (typeof (jsonData) != undefined) { for (var jitem in jsonData) { if (jitem == "insertAt" || jitem == "removeAt" || jitem == "moveTo") { continue; //解决flareJ.Base.js导致的问题。 } var newOption = document.createElement("OPTION"); newOption.text = jsonData[jitem][txtField]; newOption.value = jsonData[jitem][valField]; sel.options.add(newOption); } } }