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