document.myform.SmallClassID.options[o]<----这个是第一个元素也就是第一项。
document.myform.smallclassid.options=1;
document.myform.SmallClassID.options[document.myform.SmallClassID.length]<----那么这个该是什么,我理解不来,不懂,请解释。很不懂,真的不懂~~
document.myform.smallclassid.options=1;
document.myform.SmallClassID.options[document.myform.SmallClassID.length]<----那么这个该是什么,我理解不来,不懂,请解释。很不懂,真的不懂~~
解决方案 »
- 脚本错误:请求的操作需要提升。知道的进来看一下。
- 单击<tr>的某个td 将td中的innerHTML改为<span><input onblur=""/></span> input调用不了事件
- js obj.attachEvent() 怎么样添加参数 急~~~~
- ***{未解之迷}innerHTML() 在IE6中为什么只能用一次呢? 解答后立即给分
- 有没有哪位大哥做过widget开发?
- 一直正常运行的JS文件,突然出现错误了,为什么呢?
- 怎么样能使一个元素不能接受事件,比如我不想让<A><A/>接受onmouseover怎么实现?
- 三更半夜,在线等待高人解决!如何动态实现多个表格的嵌套?
- 有什么办法可以让鼠标左点击图片按钮时,呈现出被按下去的效果
- 在jsp中导出excel时,怎么设置时间的格式,我的时间显示不全
- 关于javascript 解析XML
- JS 里遍历HTML控件问题。急!
网页,表单,下拉列表
兄弟你对照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=gb2312" />
<title>Untitled Document</title>
<script type="text/javascript">
function init(){
alert(document.myform.SmallClassID.length);
}
</script>
</head><body onload="init()">
<form name="myform">
<select name="SmallClassID">
<option value="1">root</option>
<option value="2">Member</option>
</select>
</form>
</body>
</html>
而我的select里有5个option,那为什么下拉列表中有5个option,我已经将document.form.smallclassid.length=1设置成了1,为什么还显示出5个来
re:
select中的option数目document.myform.SmallClassID.options
re:
select中的所有option的一个数组document.myform.SmallClassID.options[document.myform.SmallClassID.length]
re:
找出select中的第x个option,x=select中的option数目这段代码有问题吧!应该是这样吧:
<!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>Untitled Document</title>
<script type="text/javascript">
function init(){
alert(document.myform.SmallClassID.options[document.myform.SmallClassID.length-1].value);
}
</script>
</head><body onload="init()">
<form name="myform">
<select name="SmallClassID">
<option value="1">root</option>
<option value="2">Member</option>
<option value="3">admin</option>
</select>
</form>
</body>
</html>
for (i=0;i<5;i++)
document.myform.SmallClassID.options[document.myform.SmallClassID.length]=new option("123")
document.myform.SmallClassID.options[document.myform.SmallClassID.length]=new option("123")
这句请解释下,是不是把123选项放进长度为1的下拉列表中?可如果我循环了5次,为什么长度会拉长到5个?我这里是将长度设置成1的呀,循环了5次,可为什么长度会拉长?然到选项一增加,length长度设置成1就失灵了吗?
re:
0,1,2,3,4是不是5个数!我这里是将长度设置成1的呀
re:
你设置在先!添加在后!哪最后的结果不应该是5 个么?循环了5次,可为什么长度会拉长?
re:
不拉长!哪说明!循环写的不对!不拉长,为什么要写循环length长度设置成1就失灵了吗?
re:
代码是从上到下依次执行的(如果没有exit).问题好好想想再写!
document.myform.smallclassid.length=1;
document.myform.SmallClassID.options[document.myform.SmallClassID.length]=new option("123")
document.myform.SmallClassID.options[document.myform.SmallClassID.length]=new option("456")
document.myform.SmallClassID.options[document.myform.SmallClassID.length]=new option("789")
</script>
等同于
<form name="myform">
<select name="smallclassid">
<option>123</option>
<option>456</option>
<option>789</option>
</select>
</form>我想问的是我在脚本里设置了length=1,为什么显示出来的长度会有三个选项那么长?请指教!
那么在脚本里的设置length=1,是不是就失灵了?
<!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>Untitled Document</title>
<script type="text/javascript">
function init(){
document.myform.SmallClassID.length=1
}
</script>
</head><body onload="init()">
<form name="myform">
<select name="SmallClassID">
<option value="1">root</option>
<option value="2">Member</option>
<option value="3">admin</option>
</select>
</form>
</body>
</html>
可为什么这句也可以给长度赋值呢?