[Javascript] Loop problem

Chris Tifer christ at saeweb.com
Tue Mar 18 07:38:14 CST 2003


 From the looks of it, this would never loop:

> for (i=1;i=<%=Numfrm%>;i++)

Should their be some of of comparison, such as:

<  or <= or > or >= or ==

When you say " var1 = var2", you're automatically setting
var1 to var2's values. == checks for equality.  That'd be where
I started to debug.

Chris Tifer

----- Original Message -----
From: "Alexandre Zglav" <azglav at heritage.ch>
To: <javascript at LaTech.edu>
Sent: Tuesday, March 18, 2003 7:44 AM
Subject: [Javascript] Loop problem


> 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.
> ----------------------------------------------------------------
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list