<!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>
</head><body>
<input type="text" name="wareIndexId" value="33333"/>
<input type="text" name="clientIndexId" value="222"/>
<input type="text" id="wareIndexId" name="wareIndexId" value="111111"/>
<input type="text" id="clientIndexId" name="clientIndexId" value="444444"/>
<script type="text/javascript">
document.getElementById("wareIndexId").value='sssss'</script>
本来是通过Id来改变对象的值的,结果失效了。他们的name属性的值相同!!!!
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<input type="text" name="wareIndexId" value="33333"/>
<input type="text" name="clientIndexId" value="222"/>
<input type="text" id="wareIndexId" name="wareIndexId" value="111111"/>
<input type="text" id="clientIndexId" name="clientIndexId" value="444444"/>
<script type="text/javascript">
document.getElementById("wareIndexId").value='sssss'</script>
本来是通过Id来改变对象的值的,结果失效了。他们的name属性的值相同!!!!
</body>
</html>
解决方案 »
- 请高手们 帮我找下 弹出窗口 JS代码里的 出错地方把
- arguments对象
- 弹出一个层,然后,鼠标可以移动到弹出层上,点上面的链接
- 英雄问题:Automation服务器不能创建对象
- 表格在firefox下被撑大的问题
- 关于窗口弹出拦截
- dojo.require("dojo.date")这个怎么用?dojo.date可以用来做什么呢?
- 请教使用javascript脚本写一个table根据鼠标经过,离开,点击时而改变颜色?
- window.open一个新窗口,怎么让最大化失效?
- ???:当我选中第一个下拉框中的某个元素时,另一个下拉框则显示相关的几个选项?--谢谢!
- JS中如何将一组字符或者数值转换成数组?
- 急,怎样动态创建文件上传元素?
在IE下最好不要用相同name吧
<!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>
</head><body>
<input type="text" name="wareIndexId" value="33333"/>
<input type="text" name="clientIndexId" value="222"/>
<input type="text" id="wareIndexId" name="wareIndexId2" value="111111"/>
<input type="text" id="clientIndexId" name="clientIndexId2" value="444444"/>
<script type="text/javascript">
document.getElementById("wareIndexId").value='sssss'</script>
本来是通过Id来改变对象的值的,结果失效了。他们的name属性的值相同!!!!
</body>
</html>
LZ是说,有俩name="wareIndexId"的input,其中的一个id="wareIndexId"
现在要改变这个id="wareIndexId"的input的值,却改了另一个没有id的input……
注:IE浏览器可能会识别name属性哦~
alert("aaaaaaaa")
document.getElementById("wareIndexId").value='sssss';//ie6 可以
alert("as")
document.getElementsByName("clientIndexId").value = "aaaaaaaaaaaaa";//ie6和ff都不正常
可以name相同,但不要name和id相同
说的对,我是用IE7调试的,所以出现了这个问题。用FF和chrome都能正常识别id和name.
我是用ActionForm获取表单元素的,所以有时可能会用到相同的name