4
我对JSON有以下查询:选择的选项不工作在IE浏览器,而在Firefox中工作。JSON:选择的选项不工作在IE中,而在Firefox中工作
我有示例数据,如:
var columnDefs = [...
{"name":"childPerformancePrice", "label":"Cosell Price", "type":"int", "control":"select", "options":performancePrices, "align":"left", "default":"", "required":false,"size": 6},
...]
性能下拉列表,如:
function getPerformancePrices(){
......
$.getJSON("?data=performancePrices", function(list) {
performancePrices.push([0, ""]);
$.each(list, function(index, item) {
performancePrices.push([item.id, item.description]);
performancePrices.sort();
});
...
});
}
例如JSON数据,如JSON.stringify(columnDefs[index])
:
{"name":"childPerformancePrice", "label":"Cosell Price", "type":"int", "control":"select", "options":[[0,""],[15000,"Band 1"],[15001,"Band 2"],[15002,"Band 3"]],"align":"left", "default":"", "required":false,"size": 6}
问:为什么下列选定的选项在编辑期间在IE中工作时不工作(即,在IE中不能正确选择)好在Firefox?
function selectCell(oColumnDef, value) {
var oSelect = createNamedElement("select", oColumnDef["name"]);
if (value == undefined) {
value = "";
}
$.each(oColumnDef["options"], function(index, item) {
var oOption = document.createElement("option");
oOption.value = item[0];
oOption.text = item[1];
if (item[1] == value) {
oOption.selected = true;
}
oSelect.options.add(oOption);
});
仅供参考,提问者试图在编辑中询问后续问题;看[这里](http://stackoverflow.com/suggested-edits/163337)。 – 2011-12-20 11:23:48