Print Page | Close Window

validating an array in javaScript

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=24939
Printed Date: 29 March 2026 at 2:07pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: validating an array in javaScript
Posted By: RCorr
Subject: validating an array in javaScript
Date Posted: 03 December 2007 at 7:04pm
Hi there,

I have a form with a series of check boxes with the same name - availability[].   The square brackets makes it as an array of course  :-) .

In javaScript, I am trying to determine if at least one of the check boxes is checked, but my code is producing an error.  This is want I have:

bAvailable = false;

for(var i=0; i < document.volunteer_app("availability[]").length; i++){
 
    if (document.volunteer_app("availability[" + i + "]").checked)
        bAvailable = true;
}

the error occurs on the following line:
  
     if (document.volunteer_app("availability[" + i + "]").checked)

Any suggestions as to what is wrong with my code.

Thanks,

RCorr
  



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net