復制代碼 代碼如下:
//下拉列表的填充
_showSchools: function (data) { //data代表是一個數據對象
                var mySelect = document.getElementById("selectSchools"); //獲取下拉框
                mySelect.options.length = 0;
                //將option添加到select標簽里面
                for (var index in data) {
                    var item = data[index];
                    var opp = new Option(item.SchoolName, item.name);  //第一個參數代表下拉框顯示的內容,第二個代表下拉框選中的內容
                    opp.name = "option" + index;
                    mySelect.add(opp);
                }
            },
//下拉列表內容的獲取
var schoolId = document.getElementById("selectSchools").value;
//我們平時是選中下拉框的值是選中的內容,而不是顯示的內容,如何獲取顯示的內容呢,下面是獲取下拉框的選中的顯示內容
function on_idmbzd_change(){ 
    var sel_obj=document.getElementById("idMbzd");
    var index=sel_obj.selectedIndex;
    alert(sel_obj.options[index].value);
    alert(sel_obj.options[index].text);
}
//單選按鈕的內容的獲取
 var chkObjs = document.getElementsByName("radio");
                var checkvalue = null;
                for (var i = 0; i < chkObjs.length; i++) {
                    if (chkObjs[i].checked) {
                        checkvalue = parseInt(chkObjs[i].value);
                    }
                }
//單選按鈕的設置
if (entity.SelectType == 1) document.getElementById("SelectType").checked = true;
if (entity.SelectType == 0) document.getElementById("UnSelectType").checked = true;
//多選框的設置
setCheckBox: function (data) {
                var courseList = document.getElementsByName("CourseList");
                for (var i = 0; i < courseList.length - 1; i++) {
                    if (courseList[i].value==data) {
                        courseList[i].checked=true;
                    }
                }
            },
新聞熱點
疑難解答
圖片精選