Need to loop through checkboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Lane

    Need to loop through checkboxes

    Browser: IE5+

    I have a form with an unknown number of checkboxes (the page is generated
    by a server-side script). I need to loop through those checkboxes, test
    whether the name of each checkbox starts with a known string and, if it
    does, clear that checkbox.

    I've tried just about everything that I can think of, but to no avail.

    Can someone tell me how to loop through the checkboxes of a form?

    TIA,

    --
    Geoff Lane
    Cornwall, UK
  • Greg Griffiths

    #2
    Re: Need to loop through checkboxes

    do something like

    for (i=0;i<document .myForm.length; i++)
    {
    if (document.myFor m[i].type=="checkbo x")
    {
    alert("Checkbox ");
    }
    }

    Geoff Lane wrote:
    [color=blue]
    > Browser: IE5+
    >
    > I have a form with an unknown number of checkboxes (the page is generated
    > by a server-side script). I need to loop through those checkboxes, test
    > whether the name of each checkbox starts with a known string and, if it
    > does, clear that checkbox.
    >
    > I've tried just about everything that I can think of, but to no avail.
    >
    > Can someone tell me how to loop through the checkboxes of a form?
    >
    > TIA,
    >
    > --
    > Geoff Lane
    > Cornwall, UK[/color]

    Comment

    Working...