Home > Web Front-end > JS Tutorial > body text

JS simple operation select and dropdownlist examples_javascript skills

WBOY
Release: 2016-05-16 16:30:19
Original
1411 people have browsed it

The example in this article describes the simple JS method of operating select and dropdownlist. Share it with everyone for your reference. The specific implementation method is as follows:

1. js select server control select and dropdownlist

1. js operation server control select

Copy code The code is as follows:


//js operation server control dropdownlist

                                                                                                                                                                 Option 1


Option 0
Option 1

JS code:

Copy code The code is as follows:
document.getElementById("ddlFolder").value="0";//0 The value of the item you want to select
2. Select an item based on Text value setting


Copy code The code is as follows:
var DropDownListCurrencyNew = document.getElementById("ddlFolder");
for(i = 0; i < DropDownListCurrencyNew.options.length; i )
{
If(DropDownListCurrencyNew.options[i].text == "Option 0")
               {
                     DropDownListCurrencyNew.options[i].selected = true;
          }
}

2. js reads the value and text of the selected item in DropDownList

Value:


Copy code The code is as follows:
var selValue = document.getElementById("DropDownList1").options[document.getElementById( "DropDownList1").selectedIndex].value;
Text:


Copy code The code is as follows:
var selText = document.getElementById("DropDownList1").options[document.getElementById( "DropDownList1").selectedIndex].text;
I hope this article will be helpful to everyone’s js and .net programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template