vba div角度选择选项
我需要选择一个选项“我想选择这个”。我尝试了下面的代码,但得到了对象所需的错误消息。这是我尝试的元素的一个示例vba div角度选择选项,vba,angular,Vba,Angular,我需要选择一个选项“我想选择这个”。我尝试了下面的代码,但得到了对象所需的错误消息。这是我尝试的元素的一个示例 ie.document.getelementbyid("sys_select.incident.u_im_reporter_grp).option(1) ie.document.getelementbyid("sys_select.incident.u_im_reporter_grp).option(0) or ie.document.getelementbyid("element.
ie.document.getelementbyid("sys_select.incident.u_im_reporter_grp).option(1)
ie.document.getelementbyid("sys_select.incident.u_im_reporter_grp).option(0)
or
ie.document.getelementbyid("element.incident.u_im_reporter_grp").focus
ie.document.getelementbyid("element.incident.u_im_reporter_grp).click
如果您无法看到下面的所有内容,请在评论回复中查看网站源代码
<div class="section-content" id="ID123" glide="true">
<div class="row">
<div class="vsplit col-sm-6">
<div class="form-group is-required" id="element.incident.u_im_reporter_grp">
<div id="label.incident.u_im_reporter_grp"
nowrap="true" type="reference" data-type="label"
choice="1">
<label class=" col-xs-12 col-md-3 col-lg-4
control-label" dir="ltr"
onclick="return labelClicked(this);"
for="sys_select.incident.u_im_reporter_grp">
<span title="" class="required-marker
label_description"
id="status.incident.u_im_reporter_grp"
aria-label="Mandatory - must be populated before Submit"
data-original-title="Mandatory - must be populated before Submit" oclass=""
mandatory="true">
</span>
<span title="" class="label-text"
data-original-title="" data-html="false">
Reporter Group
</span>
</label>
</div>
记者组
--没有--
我想选择这个
var select=gel('sys_select.incident.u_im_reporter_grp');
试试看
当ie.Busy或ie.readyState<4:DoEvents:Wend时
使物体变暗
设置a=ie.document.querySelector(“选项[value='random value']”)
a、 所选=真
这使用了选项[value='random value']
的CSS选择器,它查找第一个元素,就像使用querySelector
方法应用标记选项一样,该方法具有属性值
,值为随机值
根据注释中的HTML,这将是CSS查询结果:
此。所选
部分代码假定元素是可选择的。但是,我已经演示了如何将元素设置为变量。它不是getelementbyid
它是getelementbyid
label=“Mandatory-必须在提交之前填充”data original title=“Mandatory-必须在提交之前填充”oclass=“”Mandatory=“true”>Reporter Groupid=“sys\u original.incident.u im\u Reporter\u grp”类型=“隐藏”>id=“系统选择事件。报告者”style=“方向:ltr;“onchange=“onSelChange('sys\u select.incident.u\u im\u reporter\u grp');updateAndFlip(这是一个“事件,我的记者”);“>--None--我想选择thisvar select=gel('sys_select.incident.u_im_reporter_grp');谢谢QHarr,页面已加载完毕。我仍然收到相同的错误运行时错误'424':行集合a=ie.document.querySelector(“option[value='random value'])上需要对象我在这一行之前声明了我的对象。div元素在表单、iframe或frame中吗?可能是我的代码输入错误,但它成功了,谢谢Qhari我正在努力找到它,对不起,我是新手。哈哈,我得到了它,谢谢。这表明了我的计算机技能:)
<div class="col-xs-10 col-sm-9 col-md-6 col-lg-5 form-field input_controls">
<input name="sys_original.incident.u_im_reporter_grp"
id="sys_original.incident.u_im_reporter_grp"
type="hidden">
<input name="incident.u_im_reporter_grp"
class="direction:ltr"
id="incident.u_im_reporter_grp"
onchange="onChange('incident.u_im_reporter_grp')"
type="hidden" value="" mandatory="true">
<input name="sys_display.original.incident.u_im_reporter_grp"
id="sys_display.original.incident.u_im_reporter_grp"
type="hidden" value="">
<select name="sys_select.incident.u_im_reporter_grp"
class="form-control"
id="sys_select.incident.u_im_reporter_grp"
style="direction: ltr;"
onchange="onSelChange('sys_select.incident.u_im_reporter_grp');
updateAndFlip(this, 'incident.u_im_reporter_grp');">
<option value="">-- None --</option>
<option value="random value">I want select to this</option>
</select>
<input name="sys_display.incident.u_im_reporter_grp"
id="sys_display.incident.u_im_reporter_grp"
type="hidden" value="">
<script language="javascript">var select = gel('sys_select.incident.u_im_reporter_grp');
While ie.Busy Or ie.readyState < 4: DoEvents: Wend
Dim a As Object
Set a = ie.document.querySelector("option[value='random value']")
a.Selected = True