[thelist] Javascript array loop issues?
Jay Turley
jayturley at gmail.com
Thu Oct 29 12:58:44 CDT 2009
I think your problem may be that you are creating an object literal by
using the braces {} instead of the brackets [] to create your array
elements. Try it like this:
var getErrors = [ errorName: errorMsg, ...];
Jay
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