<select name="UnhedgedYes" id="DDLLUnhedgedYes" style="font-size: 12px;"><option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="UnhedgedYes"></span>
<select name="DDLIPRUFCE" class="DDLIPRUFCE" id="DDLIPRUFCE" style="font-size: 12px;" data-val-required="Please Select Incremental Provisioning Requirement-due to UFCE" data-val="true" data-val-number="The field DDLIPRUFCE must be a number."><option value="">[Select]</option>
<option value="1" text="0">0</option><option value="6" text="10">10</option>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="DDLIPRUFCE"></span>
<input name="hidDDLIPRUFCE" id="hidDDLIPRUFCE" type="hidden" value="" autocomplete="off" data-val-required="The hidDDLIPRUFCE field is required." data-val="true" data-val-number="The field hidDDLIPRUFCE must be a number.">
<select name="DDLIRiskW" class="DDLIRiskW" id="DDLIRiskW" style="font-size: 12px;" data-val-required="Please Select Incremental Risk Weight- due to UFCE" data-val="true" data-val-number="The field DDLIRiskW must be a number."><option value="">[Select]</option>
<option value="2" text="0">0</option><option value="1" text="25">25</option></select>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="DDLIRiskW"></span>
<input name="hidDDLIRiskW" id="hidDDLIRiskW" type="hidden" value="" autocomplete="off" data-val-required="The hidDDLIRiskW field is required." data-val="true" data-val-number="The field hidDDLIRiskW must be a number.">
我在网页中有两个三个下拉菜单。手动将第一个下拉列表选择为“否”时,其他两个下拉列表会自动显示零。点击进入时,它将移至下一个html页面。 但是,我可以使用vba在所有三个下拉列表中选择值,但是在单击Enter时再次显示两个下拉列表,请显示“选择”而不是0,并且不会移至下一页。
我尝试了For each
循环以及getElementByID
Set Post = ie.document.getElementById("DDLLUnhedgedYes")
''I din't use any index to do the job
For Each elem In Post.getElementsByTagName("option")
If InStr(elem.Value, "No") > 0 Then
elem.Selected = True
Exit For
End If
Next elem
ie.document.getElementById("DDLIPRUFCE").getElementsByTagName("option")(1).Selected = True: ie.document.getElementById("DDLIPRUFCE").FireEvent ("onchange")
ie.document.getElementById("DDLIRiskW").getElementsByTagName("option")(1).Selected = True: ie.document.getElementById("DDLIRiskW").FireEvent ("onchange")
ie.document.getElementById("btnEnter").Click
点击Enter后,网页应移至另一页。