js 动态生成下拉列表 下拉列表级联
2012-02-02 14:17
639 查看
简单的动态生成下拉列表 并且 带有级联操作
根据父级节点的值来组织子级下拉列表的值
根据父级节点的值来组织子级下拉列表的值
<!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=gb2312" /> <title>无标题文档</title> <script language="javascript"> function changeF(fatherValue) { if(fatherValue!=null) { var s2 = document.getElementById('id2'); //s2.length=1; s2.length = 1;//保留下拉列表的第一条,如果将所有的都清楚了,则值等于0即可 for(var i=0;i<3;i++) { //alert(i); var v = document.createElement('option'); v.setAttribute('value', i); var inner = document.createTextNode("我的值是_"+i+"_fatherValue="+fatherValue); v.appendChild(inner); s2.appendChild(v); } } } </script> </head> <body> 父级下拉列表: <select id="id1" name="id1" onchange="changeF(this.value);"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> 子级下拉列表: <select id="id2" name="id2" onchange="javascript:alert(this.value);"> <option value="-1">ok</option> </select> </body> </html>
相关文章推荐
- js动态生成级联下拉列表
- js动态生成级联下拉列表
- js动态生成级联下拉列表
- js动态生成级联下拉列表
- js生成级联下拉列表
- 用js+jsp实现在同一个下拉列表中,动态生成多级select选项
- 下拉列表,选中某个值通过js动态生成一个文本框,javascript,text
- js--dom--动态生成【下拉列表】
- js动态给下拉列表赋值
- 使用dwr实现下拉框级联和js实现动态选择option的selected状态方法总结
- html+js+PHP(使用了smarty模板技术)+mysql实现二级动态下拉列表(select)
- 『代码』JS封装 Ajax级联下拉列表
- 为DataGridview的Combobox列动态生成下拉列表
- JS下拉列表动态收缩与展开
- jquery ajax struts2 级联下拉框 动态生成省市
- 关于js动态向下拉列表中添加数据
- jquery mobile动态生成的下拉列表无法显示默认选择值的问题
- js实现根据下拉列表动态改变其他层
- jsp中,使用js生成动态的数据库相关的二级联动下拉框
- jquery之动态级联下拉列表