增加页面中下拉列表框中的列表项目
2017-02-07 16:19
344 查看
效果如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>增加页面中下拉列表框中的列表项目</title>
</head>
<script language="javascript" type="text/javascript">
var i,txt,val;
window.onload = function() {
var btnobj = document.getElementById("testbtn");
if(btnobj)
{
btnobj.onclick = function() { InsertItem() };
}
i=0;
}
function InsertItem()
{
i++;
var testlistobj = document.getElementById("testlist");
var option;
txt = "新增下拉列表项目" + i.toString();
val = txt + i.toString();
option = new Option(txt, val);
if(testlistobj)
{
testlistobj.options.add(option);
}
}
</script>
<body>
<select id="testlist">
</select>
<input id="testbtn" type="button" value="增加列表项目">
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>增加页面中下拉列表框中的列表项目</title>
</head>
<script language="javascript" type="text/javascript">
var i,txt,val;
window.onload = function() {
var btnobj = document.getElementById("testbtn");
if(btnobj)
{
btnobj.onclick = function() { InsertItem() };
}
i=0;
}
function InsertItem()
{
i++;
var testlistobj = document.getElementById("testlist");
var option;
txt = "新增下拉列表项目" + i.toString();
val = txt + i.toString();
option = new Option(txt, val);
if(testlistobj)
{
testlistobj.options.add(option);
}
}
</script>
<body>
<select id="testlist">
</select>
<input id="testbtn" type="button" value="增加列表项目">
</body>
</html>
相关文章推荐
- 十六.增加一个项目协作留言板功能(二)----- 建立一个任务管理的列表页面
- 在WSS的列表编辑页面增加自定义Web part
- 多选下拉列表动态增加函数
- 火狐下面的联动菜单空白问题:下拉列表无法增加
- 新闻列表页面编号连续增加
- 清楚 Visual Studio 上的 开始页面上的最近项目列表(转载)
- Appfuse开发实践(五)—— 增加校验和列表页面
- jquery通过struts2请求,返回json数据,在jsp页面形成二级联动下拉列表
- 下拉列表select动态初始化 (JSP页面)
- 一个jstl标签综合运用的例子(包括下拉列表事件处理等等),直观了解一个浏览器页面上有多少对象)
- Excel-用OFFSET和COUNTA实现动态增加下拉列表
- 用下拉列表跳转页面
- 多个下拉列表(select)不能取重复值判断-动态增加输入框-模仿CSDN结贴时分数判断-但无层提示-Ajax取值(全部源码)
- 弹出DIV层的时候,把页面上的下拉列表全部隐藏.
- Excel-用OFFSET和COUNTA实现动态增加下拉列表
- 如何根据下拉列表框的值来给textarea或者其它容器动态的增加内容?
- 2004-11-8/12 + 连动下拉列表控件(更新版,可在页面放置多个)
- dwr刷新显示页面的下拉列表,并设置默认被选中项
- Excel-用OFFSET和COUNTA实现动态增加下拉列表
- jquery通过struts2请求,在jsp页面形成二级联动下拉列表