- 30
- 0
- 约7.82千字
- 约 18页
- 2017-10-07 发布于河南
- 举报
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
您可能关注的文档
- 2010年全国自考基础会计学模拟试卷(七)(2010 national self taught basic accounting simulation paper (seven)).doc
- 2010gaokaoti(2010gaokaoti).doc
- 2010年中考复习整理初一初二思品练习卷(2010 exam review, finishing the first two days of thinking quality exercises).doc
- 2010年广州中考数学模拟试题八(In 2010, Guangzhou high school mathematics simulation test questions eight).doc
- 2010.06.03材质笔记(2010.06.03 material notes).doc
- 2010年度感动中国十大人物事迹及颁奖词(Deeds and awards speech of moving China's ten great figures in 2010).doc
- 2010年拆迁办上半年总结和下半年工作重点(2010 demolition work in the first half of the summary and focus of the second half of the work).doc
- 2010年基本能力试题特点(Basic ability examination questions in 2010).doc
- 2010年江苏省苏州市中考物理试题及答案(Physics examination questions and answers in Suzhou City, Jiangsu Province in 2010).doc
- 2010年2月互联网上刚出炉的50个段子(February 2010, the Internet just released 50 scripts).doc
最近下载
- 烫伤应急处理培训课件.ppt VIP
- 中国生物多样性保护优先区域范围.PDF VIP
- 原发性胆汁性胆管炎诊疗指南(2025年版).pptx VIP
- 汽车车载网络及总线技术 教案全套 1.1 车载网络系统认知 ---6.3 MOST总线系统认知.docx
- 2025年新疆公务员省考《行测》真题(含答案).docx VIP
- 宝洁(SIMPL).pdf
- 2024年新疆公务员省考《行测》真题(含答案).docx VIP
- 2025年济南高考德语真题试卷(含答案解析).docx
- 2025最新初一历史重要历史事件时间轴整理.docx VIP
- 2025年枣庄科技职业学院单招职业技能考试题库完整版.docx VIP
原创力文档

文档评论(0)