<html>
<head>
</head>
<body>
<form name="x" >
<input type="hidden" name="field" value="value">
<input name="model.username" type="hidden" value="1111">
</form>
<script language=javascript>
alert(document.forms[0].elements[1].value) ;
</script></body>
</html>
<head>
</head>
<body>
<form name="x" >
<input type="hidden" name="field" value="value">
<input name="model.username" type="hidden" value="1111">
</form>
<script language=javascript>
alert(document.forms[0].elements[1].value) ;
</script></body>
</html>
or
alert(document.getElementsByName("model.username")[0].value)
alert(document.x.elements("model.username").value)当大于1个字段名为"model.username"时要用
alert(document.x.elements("model.username")[0].value)但是如何判断同名字段有几个呢?document.x.elements("model.username").length
或
document.x.elements("model.username").length() 都没反应
document.getElementsByName("model.username").length
这样的取法是整个文档,而不是指定的 form 内的 model.username
的元素个数而且,我还要在 form 内,当 model.username 打勾时相应的 model.password 也要打勾比如:<form name=form1>
<input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick
</form><form name=form2>
<input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick
</form>
<input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick <input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick <input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick
</form><form name=form2>
<input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick <input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick <input type=checkbox name="model.username" onclick=''
<input type=checkbox name="model.password" onclick
</form>
var obj = document.form1.elements("model.username");
if(obj.length == "undefined") alert(obj.type);
x.elements("model.password")[X].value =x.elements("model.username")[X].value
or
if(obj.length == undefined) <= 这个有些地方好象不能支持这样写
http://community.csdn.net/Expert/topic/3857/3857742.xml?temp=.6153986如何才能确定一个表单内某个字段在多个同名字段数组中的位
如果字段值不重复的话可以使用循环得到索引位置
可是,如果允许字段值重复呢??