This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / In the following form, How to use FOR LOOP (Java script) to sum the 2 rows respectively. I mean each row gets a sum. Please show me with code,Thank you very much.<form>
<table>
<tr><td><Input type="text" name="col1_1"></td>
<td><Input type="text" name="col2_1"></td>
<td><Input type="text" name="col3_1"></td>
</tr>
<tr><td><Input type="text" name="col1_2"></td>
<td><Input type="text" name="col2_2"></td>
<td><Input type="text" name="col3_2"></td>
</tr>
</table>
</form>
-waokool(waokool);
2002-6-30
{360}
(#609665@0)
-
In the above code, I can read form data like this: c=document.theform.col1_1.value, but how to make col1_1 increasing automatically,like col2_1,col3_1? Give me some advices please, Thank u very much.
-waokool(waokool);
2002-6-30
(#609940@0)
-
见内
-xanada(㊣流水);
2002-6-30
{520}
(#609980@0)
-
The inside For Loop has some bugs.Could you check it? Thank you .for (var j = 1; j <= nCol; j++)
{
var strTextName = "document.forms[0].col" + j + "_" + i;
var nNum = eval(strTextName + ".value");
nSum = nSum + nNum;
}
-waokool(waokool);
2002-7-1
{169}
(#610490@0)
-
What bugs? detail message please, i'm ok here.
-xanada(㊣流水);
2002-7-1
(#610727@0)
-
Really? With your code, an alert with "0" pop out twice when I intend to input value. Don't mention to get the result. Sorry to respond late, I went out for national day.
-waokool(waokool);
2002-7-2
(#611840@0)
-
呵呵,算了,给你把整个文件贴上来好了
-xanada(㊣流水);
2002-7-2
{1171}
(#612095@0)
-
Hi,Xanada. Thank you for your code. And your advice is sincere and right. But to be honest,I am not and won't be an IT guy. My major has connection with IT, and what i am doing is a small project(In my project, I use javascript,vbscript,asp,and even java). But for an outsider, I need learn everything from start, sometimes just too anxious to calm down to read books.I appreciate all the help I get here. This is really the best forum I've ever seen.And thank you all.
-waokool(waokool);
2002-7-2
{380}
(#612216@0)
-
收到,了解,箍蜡。
-xanada(㊣流水);
2002-7-2
(#612247@0)
-
The problem here is actually how to make browser think the i and j in the field name(coli_j) is variables but not constant? How can I ?Thanks a lot
-waokool(waokool);
2002-7-1
(#610550@0)
-
给你个苯办法,动态生成该段javascript的code。
-guestagain(guest again);
2002-7-1
(#610610@0)
-
Could you tell me what the dummy way is ? Thanks.
-waokool(waokool);
2002-7-1
(#610638@0)
-
你不会用document.write?
-guestagain(guest again);
2002-7-1
(#610687@0)
-
不过这样其实没有什么必要,不如试试form.elements[“col” + i + "_" + j].value
-guestagain(guest again);
2002-7-1
(#610710@0)
-
我说这位 DX 怎么就不试试偶说的方法呢
-xmlhttprequest(xmlhttp);
2002-7-1
{1068}
(#611078@0)
-
1. 有可能Netscape不通过 2. 如果每行的TextInput之间夹杂个把CheckInput, HiddenInput也不行。
-xanada(㊣流水);
2002-7-1
(#611153@0)
-
1. 坚持使用 w3c dom 即可。 2. 随便加个 custom attribute 就可以乐。
-xmlhttprequest(xmlhttp);
2002-7-1
(#611221@0)
-
请教,第一个能否详细说说?因为我印象中这段代码在NS4估计不通过。
-xanada(㊣流水);
2002-7-1
(#611247@0)
-
nn4? 可能。我顶多支持到 nn6.2,再烂的实在没办法支持。;-) 偶脚得只用 w3c dom 已经很不爽了,再要支持 nn4 ----
-xmlhttprequest(xmlhttp);
2002-7-1
(#611283@0)
-
Did you test the code? doesn't work. Thank you anyway
-waokool(waokool);
2002-7-2
(#611868@0)
-
of cuz i did test it... it works on IE6.... and i believe it should work w/ ie 55. and i know it won't work w/ NN, but if u modify innerText, it should work w/ nn6.2+
-xmlhttprequest(xmlhttp);
2002-7-2
(#612068@0)