[Javascript] Loop problem
Alexandre Zglav
azglav at heritage.ch
Tue Mar 18 06:44:39 CST 2003
Hello all.
I quite new to javascript and I have a problem with a loop and I just cant
find a solution to it on the internet.
I am trying to validate a for m with a variable amount of fields.
Here is the code i am using :
<!--
function CheckForm(form1) {
var why ="";
for (i=1;i=<%=Numfrm%>;i++)
why += checkName(form1.name[i].value);
if ( why != "") {
alert(why);
return false;
}
}
function checkName (strng) {
var error = "";
//test of the filling
if (strng == "") {
error = "you didn' enter a username. \n";
}
return error;
}
-->
Note that <%=Numfrm%> is a the variable i am retrieving from ASP. It
returns me an integer value chosen in an earlier field.
Now my problem is at this point :
why += checkName(form1.name[i].value);
It seems that [i] is not accepted as I always get an error at this level
in my script debugger.
Can someone help me with this ?
Thanks in advance.
Best regards.
_____________________________________
IT Projects
Alexandre Zglav
Heritage Finance and Trust Company
12 cours des bastions
1205 Geneva
Switzerland
Phone : ++ 41 22 817 31 68
----------------------------------------------------------------
This document should only be read by those persons to whom it is
addressed and is not intended to be relied upon by any person
without subsequent written confirmation of its contents. If you
have received this e-mail message in error, please destroy it
and delete it from your computer.
Any form of reproduction, dissemination, copying, disclosure,
modification, distribution and/or publication of this E-mail
message is strictly prohibited.
----------------------------------------------------------------
More information about the Javascript
mailing list