gpt4 book ai didi

html - 一个 HTMLInputElement 被点击,一个 HTMLOptionElement 被点击

转载 作者:可可西里 更新时间:2023-11-01 12:54:04 25 4
gpt4 key购买 nike

我正在尝试编写 vba 代码来为我填写网络表单和单击按钮。我循环遍历页面上的各种 option 标记以选择我想要的标记。当我到达它时,我想选择它,但我不确定语法。

Dim htmlO As HTMLOptionElement
For Each htmlO In Object.getElementByTagName("option")
If Trim(htmlO.value) = "INS" Then
htmlO.???? (click? select?)
Exit For
End If
Next

这是网页的 HTML:

<select gtbfieldid="40" id="menu" name="pv_choice">
<option selected="selected" value="ZZZ">Choose Menu Option
</option><option value="BL_COMP">Blanket Companies
</option><option value="CARR_SEARCH">Carrier Search
</option><option value="PASSWORD">Change Password
</option><option value="FED_REG">FMCSA Register
</option><option value="FEEDBACK">Feedback
</option><option value="HOME">Home Page
</option><option value="INS">Insurance Filing
</option><option value="OOS_LIST">Out Of Service Carriers
</option></select>

我想选择“INS”选项。

最佳答案

Dim StrFindText  as string
Dim htmlSelect As HTMLSelectElement
Dim htmlItemOption As IHTMLOptionElement

Set htmlSelect = Object.getElementById("menu")
StrFindText = "INS"

For i = 0 To htmlSelect.options.length - 1
htmlItemOption = htmlSelect.options(i)
' UCase(htmlItemOption.text) = UCase(StrFindText) ' if find text options
If UCase(htmlItemOption.value) = UCase(StrFindText) Then
htmlItemOption.selected = True
Exit For
End If
Next i

关于html - 一个 HTMLInputElement 被点击,一个 HTMLOptionElement 被点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2373881/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com