Almost all HTML tags can be called HTML controls, such as select, input, div, and table. Html Tag operations are very popular. How to use javascript to operate HTML controls is described below:
The Code is as follows:
// Fill in the drop-down list
_ ShowSchools: function (data) {// data indicates a data Object
Var mySelect = document. getElementById ("selectSchools"); // obtain the drop-down list
MySelect. options. length = 0;
// Add option to the select label
For (var index in data ){
Var item = data [index];
Var opp = new Option (item. SchoolName, item. name); // The first parameter indicates the content displayed in the drop-down box, and the second parameter indicates the content selected in the drop-down box.
Opp. name = "option" + index;
MySelect. add (opp );
}
},
// Retrieve the content from the drop-down list
Var schoolId = document. getElementById ("selectSchools"). value;
// We usually select the selected content in the drop-down box instead of the displayed content. How can we get the displayed content? The following shows how to get the selected content in the drop-down box.
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 );
}
// Obtain the content of the single-choice button
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 );
}
}
// Set the radio button
If (entity. SelectType = 1) document. getElementById ("SelectType"). checked = true;
If (entity. SelectType = 0) document. getElementById ("UnSelectType"). checked = true;
// Set the multiple choice box
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;
}
}
},