【发布时间】:2020-03-06 04:42:39
【问题描述】:
我正在尝试使用vba从下拉框中选择值,下拉框的代码块如下
<input type="text" id="form_autocomplete_input-1542902425322" list="form_autocomplete_suggestions-1542902425322" placeholder="Search keyword or select filter" role="combobox" aria-expanded="false" autocomplete="off" autocorrect="off" autocapitalize="off" aria-autocomplete="list" aria-owns="form_autocomplete_suggestions-1542902425322 form_autocomplete_selection-1542902425322">
如果form_autocomplete_suggestions-1542902425322 的值是静态的,我会使用.Document.getElementById("form_autocomplete_suggestions-1542902425322").Value = "Role: Student",但这似乎是一个随机生成的数值。
我看过了,看来我不能简单地添加通配符,例如.Document.getElementById("form_autocomplete_suggestions-*").Value = "Role: Student"
而且由于它是随机生成的,而且数字如此之长,它不能循环遍历一个值数组。所以我不确定如何解决这个问题。
【问题讨论】:
-
那么表单上会有多少个文本框?您不必遍历数字数组,您可以查看以
.getElements等开头的选项,将它们放入集合并在必要时循环它们。你能多解释一下对象的数量,或者贴一张页面的屏幕截图吗? -
您好,不知道您所说的表单是什么意思?问题是下拉框的值发生了变化!image 所以我不能使用
.Document.getElementById("form_autocomplete_suggestions-1542902425322").Value = "Role: Student",因为 1542902425322 的值现在已更改为其他值。