[thelist] Javascript array loop issues?

Jay Turley jayturley at gmail.com
Thu Oct 29 13:06:01 CDT 2009


Damn! Look what I get for replying from my phone and not reading the  
whole message :(

The problem is in your loop too. Okay, first, js arrays are not  
hashes, so the object literal is just fine. Take out the new Array  
line- you don't need it.

Next, it's unclear from the loops exactly what you are trying to do.  
It looks like you are trying to match the keys of the getErrors to DOM  
elements. It would be very helpful if you can post the HTML which this  
is being used with, or link to a sample page. Do that and I'll be glad  
to look at it.



On Oct 29, 2009, at 10:05 AM, Tris <beertastic at gmail.com> wrote:

> Hi all..
> Major Javascript woes today...
> I'm learning.. well, relearning Ajax.. I've a from that IU wanna
> display dynaimic errors..
> Anyhoo, I've prepared an array of my errors in an array (inputId :  
> message)
> I want to loop through that array, and then IF there's a message
> value, then echo it...
> For this example, i'm just echoing some alerts.. but I'm not getting  
> any...
>
> What ROOKIE mistake am I making today? ;-p
> Peace and love...
> Tris..
>
> ==================================
>
> <script type="text/javascript">
>   alert('start');
>
>   var getErrors = new Array();
>   var getErrors = {"lookingWhat":"Who are you looking for?",
>                           "genderWhat":"What gender are you?",
>                           "passwordDifferent":"",
>                           "emailRegistered":"",
>                           "emailInvalid":"Invalid Email Address",
>                           "FieldsEmpty":"Pleace complete all fields"};
>
>   for (i=0;i<getErrors.length;i++) {
>       for(getErrors in value) {
>           var getKey = $('#'+getErrors[i]);
>           var getVal = value[i];
>           if (getVal.val() == '') {
>               alert('is an error');
>           } else {
>               alert('no error');
>           }
>       }
>   }
>
> alert('end');
> </script>
> -- 
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !



More information about the thelist mailing list