function BindSelect(id,dataList,fieldtext,fieldValue) {
//绑定某一个数据源,fieldtext为需要绑定的文本字段,fieldValue为需要绑定的value字段
var select = $("#" + id)[0];
for (var i = 0; i < dataList.length; 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 < OptionList.length; 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 < len; i++) {
if (select.options[i].value == selectValue) {
select.options[i].selected = true;
break;
}
}
}
function selectOneOptionByIndex(id, index) {//<SPAN style="FONT-FAMILY: Arial, Helvetica, sans-serif">//根据下标,选中一个选项</SPAN>
var select = $("#" + id)[0];
var len = select.options.length;
if (index >= 0 && index <= len) {
select.options[index].selected = true;
}
}