"/> ">

Home  >  Article  >  Web Front-end  >  Detailed explanation of how javascript operates server control code examples

Detailed explanation of how javascript operates server control code examples

伊谢尔伦
伊谢尔伦Original
2017-07-24 10:24:311343browse

js select server control select and dropdownlist

1. js operation server control select

//js操作服务器控件dropdownlist
    
        选项0   
   选项1  
    
 
  选项0
  选项1 

JS code:

document.getElementById("ddlFolder").value="0";//0为你要选中的项的value

2 . Select an item based on the Text value setting

var DropDownListCurrencyNew =  document.getElementById("ddlFolder");
for(i = 0; i < DropDownListCurrencyNew.options.length; i++)
{
          if(DropDownListCurrencyNew.options[i].text == "选项0")    
           {
               DropDownListCurrencyNew.options[i].selected = true; 
          }
}

js reads the value and text of the DropDownList selected item

Value:

var selValue = document.getElementById("DropDownList1").options[document.getElementById("DropDownList1").selectedIndex].value;

Text:

var selText = document.getElementById("DropDownList1").options[document.getElementById("DropDownList1").selectedIndex].text;


The above is the detailed content of Detailed explanation of how javascript operates server control code examples. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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