我遇到了问题,我创建了一个循环来创建html中的复选框。我试着给复选框id和名字“i”但是当我按下按钮然后它说“对象需要(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
答案 0 :(得分:2)
您需要首先使用GetElementById通过其ID获取Checkboxes对象(链接中描述了Javascript函数,但它与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