YZlat
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(...).inFie ld' is not supported"
Here is my code:
For i=1 to 10
inField= "opt" & i
'check if checkbox is checked
if document.forms(0).inField.
......
end if
Next
I get an error "Object property or method 'document.forms(...).inFie
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Demo works. inField is a variable not a literal, so you need to use .elements(inField) not .inField
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