JS中提取表格一列id为13,23,33···的文本域内容,表格会自动新增加行数,然后内容相加,这段代码错在哪
function$(abc){returndocument.getElementById(abc)};vartbl=document.getElementById('ta...
function $(abc){return document.getElementById(abc)};
var tbl = document.getElementById('tab');
var lastRow = tbl.rows.length;
var changdu = ( lastRow - 2 )*10 +3;
for(var i = 13;i<=changdu;i=i+10){
$(i).onkeyup = function(){
var tbl = document.getElementById('tab');
var lastRow = tbl.rows.length;
var changdu = ( lastRow - 2 )*10 +3;
for(var i = 13;i<=changdu;i=i+10){
if(changdu < 2){ var text = +$("13").value; }
else {var text = (+$("13").value)+(+$(j).value);}}
$("gz").value = text;
for(var i = 13;i<=changdu;i=i+10){
$(i).onkeyup = function(){
for(var j = 13;j<=changdu;j=j+10){
if(changdu < 23){ var text = +$("13").value; }
else {var text = ((+$("13").value)+(+$("'+j+'").value));}
}
$("gz").value = text;
}
}
前面的修改了,为什么else后的语句不执行?????是哪里出问题了? 展开
var tbl = document.getElementById('tab');
var lastRow = tbl.rows.length;
var changdu = ( lastRow - 2 )*10 +3;
for(var i = 13;i<=changdu;i=i+10){
$(i).onkeyup = function(){
var tbl = document.getElementById('tab');
var lastRow = tbl.rows.length;
var changdu = ( lastRow - 2 )*10 +3;
for(var i = 13;i<=changdu;i=i+10){
if(changdu < 2){ var text = +$("13").value; }
else {var text = (+$("13").value)+(+$(j).value);}}
$("gz").value = text;
for(var i = 13;i<=changdu;i=i+10){
$(i).onkeyup = function(){
for(var j = 13;j<=changdu;j=j+10){
if(changdu < 23){ var text = +$("13").value; }
else {var text = ((+$("13").value)+(+$("'+j+'").value));}
}
$("gz").value = text;
}
}
前面的修改了,为什么else后的语句不执行?????是哪里出问题了? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询