function BindSelect(id,dataList,fieldtext,field,Value) { //綁定某一個資料來源,fieldtext為需要綁定的文字字段,fieldValue為需要綁定的value字段
var select = $("#" id)[0];
for (var i = 0; i select.options.add(new Option(eval("dataList[" i "]." fieldtext), eval("dataList[" i "]." fieldValue )));
}
}
function BindSelectOptions(id, OptionList) {
var select = $("#" id)[0];
for (var i = 0; i select.options.add(new Option(OptionList[i].Text, OptionList[i].Value));
}
}
function ClearAllItems (id) {//清空所有的選項
var select = $("#" id)[0];
select.options.length = 0;
}
function AddOneItem(id, text, value) {//新增一個選項
var select = $("#" id)[0];
select.options.add(new Option(text, value));
}
function selectOneOption(id, selectValue) {//根據值,選取一個選項
var select = $("#" id)[0];
var len = select.options.length;
for (var i = 0; i if (select.options[i].value == selectValue) {
select.options[i].selected = true;
break ;
}
}
}
function selectOneOptionByIndex(id, index) {////根據下標,選取一個選項
var select = $("#" id)[0];
var len = select.options.length;
if (index >= 0 && index select.options[index].selected = true;
}
}