js 操作select 下拉框(JS操作选择下拉框).docVIP

  • 30
  • 0
  • 约7.82千字
  • 约 18页
  • 2017-10-07 发布于河南
  • 举报

js 操作select 下拉框(JS操作选择下拉框).doc

js 操作select 下拉框(JS操作选择下拉框)

js 操作select 下拉框(JS操作选择下拉框) JS operation select drop-down box Turn from /blog/524172 select id=, ddlResourceType, onchange=, getValue (this) /select Dynamically delete all options in select: Document.getElementById (ddlResourceType).Options.length=0; Dynamically delete an item in select option: Document.getElementById (ddlResourceType).Options.remove (indx); Dynamically add item select in option: Document.getElementById (ddlResourceType).Options.add (New Option (text, value)); It can be tested successfully on both IE and FireFox, and I hope you can use it later. In fact, the standard DOM operation can also be, that is, document.createElement, appendChild, removeChild and the like. Value aspect Function getValue (obj) { Var m=obj.options[obj.selectedIndex].value Alert (m); / / value Var n=obj.options[obj.selectedIndex].text Alert (n); / / get the text } ============================================================================== 1 whether the test is checked If (objSelect.selectedIndex - 1) { / / that the selected } else { That / / not selected } 2 deletes the selected item ObjSelect.options[objSelect.selectedIndex] = null; 3 add item ObjSelect.options[objSelect.length] = new Option (hello, hello); 4 modify the selected item ObjSelect.options[objSelect.selectedIndex] = new Option (hello, hello); 5 gets the text of the selected item ObjSelect.options[objSelect.selectedIndex].text; 6 gets the value of the selected item ObjSelect.options[objSelect.selectedIndex].value; ====================================================================== %@LANGUAGE= VBSCRIPT CODEPAGE= 936% DOCTYPE, HTML, PUBLIC, -//W3C//DTD, XHTML, 1, Transitional//EN, /TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns= /1999/xhtml head meta http-equiv= Content-Type content= text/html; charset=gb2312 / titleJS dynamically adds options operations to select, and [IE and FireFox are compatible with]/title script language=, JavaScript, type=, text/javascript Function xlbchange (s) { Switch (s) { Ca

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档