Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

asked on

VBScritp loop through checkboxes

I am trying to use VBScript to loop through a number of checkboxes on my form. All the checkboxes named "checnkbox1" through "checkbox10"

Here is my code:

For i=1 to 10
          inField= "opt" & i
         
          'check if checkbox is checked
          if document.forms(0).inField.Checked then    <--EROR HERE
                                       
      ......
          end if
     Next

I get an error "Object property or method 'document.forms(...).inField' is not supported"
ASKER CERTIFIED SOLUTION
Avatar of callrs
callrs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of b0lsc0tt
YZlat,

I may have misunderstood your question but if you have provide each checkbox tag with a name attribute value of checkbox# (# is 1-10) then what is opt# (i.e. inField)?  Try changing opt to checkbox and does that correct the problem?  If I have misunderstood or am missing some info then please elaborate.

Let me know if you have any questions or need more information.

b0lsc0tt
Avatar of callrs
callrs

Demo works. inField is a variable not a literal, so you need to use .elements(inField) not .inField