`
Franciswmf
  • 浏览: 780332 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

用document.form.missiveType和document.getElementsByName("missiveType")的比较

 
阅读更多
对于div中动态获取的相同name的复选框,用document.form.missiveType和document.getElementsByName("missiveType")的比较
------------------------------------------------------
if(document.form.missiveType.length>0) {
for (i = 0; i < document.form.missiveType.length; i++) {
if (document.form.missiveType[i].checked==true) {
flag=1;
break;
} else {
flag=0;
}
}
if(flag==0){
alert('请至少选择一个公文类别');
document.forms[0].mm.focus();
isTrue=false;
return;
}
  }
for (i = 0; i < document.form.missiveType.length; i++) {
if(document.form.missiveType[i].checked){
arr=arr+document.form.missiveType[i].value+",";
}
}

--------------------------------------------------
var es=document.getElementsByName("missiveType");
alert(es.length+":个数");
if(es.length>0) {
for (i = 0; i < es.length; i++) {
if (es[i].checked==true) {
flag=1;
break;
} else {
flag=0;
}
}
if(flag==0){
alert('请至少选择一个公文类别');
document.forms[0].mm.focus();
isTrue=false;
return;
}
  }
for (i = 0; i < es.length; i++) {
if(es[i].checked){
arr=arr+es[i].value+",";
}
}
--------------------------------------------------------
分享到:
评论

相关推荐

    javascript的IE和Firefox兼容性汇编

    javascript的IE和Firefox兼容性汇编 1. document.form.item 问题 (1)现有问题: 现有代码中存在许多 document....又如:document.getElementsByName("inputName")(1) 改为 document.getElementsByName("inputName")[1]

    没有document.getElementByName方法

    首先声明的是: document... 然而可以用很浅显的方式得到如: var fn = document.getElementsByName(“form_write”)[0]; //得到这个form下的对象 fn.content.value;//就直接去用这个对象取值就可以了。 document.getEl

    IE中getElementsByName()对有些元素无效的解决方案

    注意:在IE下有些节点是没有name 属性的,就是用document.getElementsByName获取不到的。只有下面的tag有name属性: A, APPLET, attribute, BUTTON, EMBED, FORM, IMG, INPUT type=button, INPUT type=checkbox, ...

    JavaScript权威指南

    Document Information Properties Section 14.5. Forms Section 14.6. Images Section 14.7. Links Section 14.8. Anchors Section 14.9. Applets Section 14.10. Embedded Data Chapter 15. Forms...

    jsp有关表单的操作

    jsp中有关表单的一些操作,对初学这有很大帮助例子1:复选框例子 &lt;form method=post action=... alert(document.getElementsByName("ch1")[0].value); } //document.forms[0].submit(); } 例子2:单选按钮

    将HTMLCollection/NodeList/伪数组转换成数组的实现方法

    2,通过document.forms,Form.elements,Select.options,document.getElementsByName() ,document.getElementsByTagName() ,childNodes/children 等方式获取的集合(HTMLCollection,NodeList)等。 3,特殊写法...

    js中将HTMLCollection/NodeList/伪数组转换成数组的代码

    2,通过document.forms,Form.elements,Select.options,document.getElementsByName() ,document.getElementsByTagName() ,childNodes/children 等方式获取的集合(HTMLCollection,NodeList)等。 3,特殊写法...

    浏览器兼容的JS写法总结

    一、元素查找问题 1. document.all[name] ... 如:IE中可以使用document.forms(“formName”)来返回名字为”formName”的Form,但在Firefox却行不通。  (2)解决方法:使用[],上例中可以改为document.fo

    js使用小技巧

    document.getElementsByName("r1"); document.getElementById(id); 定时 timer=setInterval("scrollwindow()",delay); clearInterval(timer); UNCODE编码 escape() ,unescape 父对象 obj.parentElement...

    FCKeditor-test

    document.getElementsByName("exPlainInfo.sittypeid.id")[0].value=parent.document.getElementById("sitTypeInfoId").value; var textInner=parent.document.getElementById("sitTypeInfoId").options[parent....

    js实现checkbox全选和反选示例

    function selectAll(form) { var obj = document.getElementsByName(‘selectall’); var cks = document.getElementsByTagName(“input”); var ckslen = cks.length; for(var i=0;i&lt;ckslen-1;i++) { if...

    在b/s开发中经常用到的javaScript技术整理

    var a = document.getElementsByName(str); var n = a.length; for (var i=0; i; i++) a[i].checked = window.event.srcElement.checked; } function checkItem(str) { var e = window.event.srcElement...

    基于HTTP长连接的服务器推技术的php 简易聊天室

    首先是首页,包含一个文本输入和一个显示聊天内容的iframe,还有一个隐藏iframe用来提交form表单: 复制代码 代码如下: &lt;?php //chat.php header(‘cache-control: private’); header(‘Content-Type: text/html...

    表单验证Validator v1.0(CHM) 下载

    在Windows Server 2003下用IE6.0+SP1和Mozilla Firefox 1.0测试通过; 在Lunix RedHat 9下的Netscape测试通过; Validator 完整代码: /************************************************* Validator v1.01...

    jQuery实现统计复选框选中数量

    代码很简介,功能也很简单,但是却很实用,这里就不细说明了直接上代码 jQuery代码: ... var items = document.getElementsByName(“check”);  for(var i=0;i&lt;items.length;i++){  if(ite

    编译的 HTML 帮助文件 (.chm) DHTML手册

    如果要在 HTC 文件中编码脚本,应使用 element.document 来引用主文档的 document 对象。 示例 下面的例子使用了 document 对象检查文档标题并在消息框中显示该标题(如果非空)。 if (document.title!="") alert(...

Global site tag (gtag.js) - Google Analytics