Multiple text boxes with the same name

Giganews Newsgroups
Subject: Multiple text boxes with the same name
Posted by:  elliespostb…@hotmail.com (Ellie100)
Date: 23 Jul 2003

Hi all

I'm a first-time poster and would appreciate some help with a problem
I'm having.  I have an HTML form (UPD_BUDG) which includes 10
checkboxes, all with the same name (Apply_Phasing_CB) but different
values.  On its own (i.e. before I add any JS) the form works fine.

I need to add an onSubmit function which counts how many of the boxes
are checked.  Here is the script I have used:

function check_form()
{
var check_count = 0;
for(i = 0; i < 10; i++)
    {
      if (document.forms.UPD_BUDG.Apply_Phasing_CB[i].checked)
          {
            check_count++;
          }
    }
  return check_count;
}

When I run this I get the error message
'document.forms.UPD_BUDG.Apply_Phasing_CB[...].checked is not an
object'.  I am running this on IE 5.

Can anyone advise me on what I'm doing wrong?

Thanks

Ellie

Replies