一个function,没有循环但是老是循环两次 老大,代码哪里出了问题,把问题代码贴出来就行了,实在不能精简的,也要注释一下吧!其实,你在代码精简的同时,往往自己就发现问题之所在了,真的!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 方法功能是这样的: 有一个id为report_table2的表,现在表的第一行id是guest_tr,第二行id是host2,一点提交按钮触发这个info()方法,先判断第一行是不是空,如果不是,取出第一行第二行的每个单元格的name之类的属性拼成一个字符串,以下细节没有什么问题,就是不明白,这个方法总是要循环两次,所有得到的字符串总是重复两遍的function info(){ row = document.getElementById("host2"); var objtr1=document.getElementById("guest_tr"); var oTbody=report_table2.children.item(0); if(objtr1.children.item(2)==undefined) { alert("不能为空!); return false; } else { for(var j=2;j<objtr1.children.length;j++) { if(row.children.item(j-1+cnum).name==undefined) hinfo=0; else { hinfo=objtr1.children.item(j).colSpan; cnum+=(hinfo-1); } hostinfo+=objtr1.children.item(j).name+"#"+hinfo+"@"; } hostinfo+="/"; for(var j1=1;j1<row.children.length;j1++) { if(row.children.item(j1).name!=undefined) hostinfo+=row.children.item(j1).name+"#"+"0"+"@"; else hostinfo=hostinfo; } hostinfo=hostinfo.substring(0,hostinfo.length-1); return true; } } javascript 查找问题 谢谢啦 急 table offsetLeft取值问题 有没有学习js高级的文档或是好的网站,总感觉用的时候不够用,谢谢 动态向DIV里写入JS jquery实现鼠标经过显示对应的层 CSDN 的 JavaScript Framework 求助高手 插入重复的div ID的问题 答对立即给分!!! 怎样编写mediaplay的进度条?? 如何在一个框架里同时按制别外两个框架 为什么gridview控件没有数据时整个控件不显示 如何在一个页面显示N个计时器?
有一个id为report_table2的表,现在表的第一行id是guest_tr,第二行id是host2,一点提交按钮触发这个info()方法,先判断第一行是不是空,如果不是,取出第一行第二行的每个单元格的name之类的属性拼成一个字符串,以下细节没有什么问题,就是不明白,这个方法总是要循环两次,所有得到的字符串总是重复两遍的
function info()
{
row = document.getElementById("host2");
var objtr1=document.getElementById("guest_tr");
var oTbody=report_table2.children.item(0);
if(objtr1.children.item(2)==undefined)
{
alert("不能为空!);
return false;
}
else
{
for(var j=2;j<objtr1.children.length;j++)
{
if(row.children.item(j-1+cnum).name==undefined)
hinfo=0;
else
{
hinfo=objtr1.children.item(j).colSpan;
cnum+=(hinfo-1);
}
hostinfo+=objtr1.children.item(j).name+"#"+hinfo+"@";
}
hostinfo+="/";
for(var j1=1;j1<row.children.length;j1++)
{
if(row.children.item(j1).name!=undefined)
hostinfo+=row.children.item(j1).name+"#"+"0"+"@";
else
hostinfo=hostinfo;
}
hostinfo=hostinfo.substring(0,hostinfo.length-1);
return true;
}
}