Javascript操作下拉框的常用方法
function AddDropDownList(id,fatherCtl)
{
if(!document.getElementById(id))
{
var ddl = document.createElement('select');
ddl.setAttribute("id",id);
if(fatherCtl&&document.getElementById(fatherCtl))
document.getElementById(fatherCtl).appendChild(ddl);
else
document.body.appendChild(ddl);
}
}
//删除指定的下拉框
function RemoveDropDownList(id)
{
var ctl = document.getElementById(id);
if(ctl)
ctl.parentNode.removeChild(ctl);
}
//给下拉框添加选项
function AddDDDLOption(id,text,value)
{
var ctl = document.getElementById(id);
if(ctl)
{
ctl.options[ctl.options.length] = new Option(text,value);
}
}
//删除所有选项
function RemoveAllDDLOptions(id)
{
var ctl = document.getElementById(id);
if(ctl)
{
ctl.options.length=0;
}
}
//删除指定索引的选项
function RemoveDDLOption(id,index)
{
var ctl=document.getElementById(id);
if(ctl && ctl.options[index])
{ &n
相关文档:
1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
2. <body onselectstart="return false"> 取消选取、防止复制
3. onpaste="return false" 不准粘贴
4. oncopy="return false;" oncut="re ......
写一个小系统时,需要动态添加表单元素,按自己的实现方法写了这篇教程!
我想各位在很多网站上都看到过类似的效果!
1、先用document.createElement方法创建一个input元素!
程序代码
var newInput = document.createElement("input");
2、设定相关属性,如name,type等
程序代码
newInput.type=mytype;
newInput.name ......
1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
2. <body onselectstart="return false"> 取消选取、防止复制
3. onpaste="return false" 不准粘贴
4. oncopy="return false;" oncut="return ......
JavaScript函数语法
函数是进行模块化程序设计的基础,编写复杂的Ajax应用程序,必须对函数有更深入的了解。javascript中的函数不同于其他的语言,每个函 数都是作为一个对象被维护和运行的。通过函数对象的性质,可以很方便的将一个函数赋值给一个变量或者将函数作为参数传递。在继续讲述之前,先看一下函数的 使用语法: ......