1
votes

I got a problem, I made a loop to create checkboxes in html. I try to give the checkbox the id and name "i" But then when I press the button then it says "Object required (i)"

For i = 0 To UBound(arrDrives)  

strHTML = strHTML & "<input type='checkbox' name='"& i &"' id='"& i &"'>"

Next

Sub Start_Button()
For i = 0 To UBound(arrDrives)  
If i.checked Then DataA.InnerHTML = "Det dur"
Next
End Sub
1

1 Answers

2
votes

You need to get the Checkboxes Objects first by their ID using GetElementById (Javascript function is described in the link, but it is compatible with VBScript)

For i = 0 To UBound(arrDrives)  
     strHTML = strHTML & "<input type='checkbox' name='"& i &"' id='"& i &"'>"
Next

' ...     

Sub Start_Button()
    For i = 0 To UBound(arrDrives)  
        If document.GetElementById(i).checked Then 
            DataA.InnerHTML = "Det dur"
        End If
    Next
End Sub