JavaScript Operations HTML Control instance (JavaScript add HTML) _ Basics

Source: Internet
Author: User

Copy Code code as follows:

The fill of the Drop-down list

_showschools:function {//data represents a data object

var myselect = document.getElementById ("Selectschools"); Get Drop-down Box
mySelect.options.length = 0;
Add option to the SELECT tag
For (var index in data) {
var item = Data[index];
var opp = new Option (item.  Schoolname, Item.name); The first argument represents what is displayed in the Drop-down box, and the second represents what is selected by the Drop-down box
opp.name = "option" + index;
Myselect.add (OPP);
}
},

Access to Drop-down list content
var SchoolID = document.getElementById ("Selectschools"). Value;

We usually select the value of the Drop-down box is selected, rather than the display of content, how to get the displayed content, the following is to get the dropdown box of the selected display content
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);
}

//access to the contents of the radio 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);
                    }
               }

//radio button Settings
if (entity. SelectType = = 1) document.getElementById ("SelectType"). Checked = true;
if (entity. SelectType = = 0) document.getElementById ("Unselecttype"). Checked = true;

Settings for multiple-selection boxes
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;
}
}

},

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.