我需要填充每个更新网站的下拉列表。
使用VBScript我可以使用IE.Document.GetElementById("Blahblah").FireEvent
- 但这不适用于VB.NET。所以我尝试使用RaiseEvent
和InvokeMember
代替,但似乎都没有用于更新表单。
HTML是:
<div class="elements">
<select name="_ctl0:MainContent:generateECodes_PackageDropdown" onchange="javascript:setTimeout('__doPostBack(\'_ctl0$MainContent$generateECodes_PackageDropdown\',\'\')', 0)" language="javascript" id="generateECodes_PackageDropdown">
<option selected="selected" value="0">- Select a package -</option>
<option value="272">McAfee Internet Security</option>
<option value="273">3-User McAfee Internet Security</option>
<option value="274">McAfee Total Protection</option>
<option value="275">3-User McAfee Total Protection</option>
<option value="379">McAfee Mobile Security - Smartphone Edition</option>
<option value="381">McAfee Mobile Security - Tablet Edition</option>
<option value="430">McAfee LiveSafe</option>
</select>
<select name="_ctl0:MainContent:generateECodes_TermDropdown" onchange="javascript:setTimeout('__doPostBack(\'_ctl0$MainContent$generateECodes_TermDropdown\',\'\')', 0)" language="javascript" id="generateECodes_TermDropdown" disabled="disabled">
<option selected="selected" value="- Select a term -">- Select a term -</option>
</select>
<select name="_ctl0:MainContent:generateECodes_Languages" onchange="javascript:setTimeout('__doPostBack(\'_ctl0$MainContent$generateECodes_Languages\',\'\')', 0)" language="javascript" id="generateECodes_Languages" disabled="disabled">
<option selected="selected" value="- Select a language -">- Select a language -</option>
</select>
<a id="generateECodes_VanityURL"></a>
<select name="_ctl0:MainContent:generateECodes_StoreNumber" id="generateECodes_StoreNumber" disabled="disabled" style="display:none">
<option value="0">- Select a store -</option>
<option selected="selected" value="1">1049 - Default Store</option>
</select>
<input name="_ctl0:MainContent:generateECodes_Required" type="text" maxlength="2" id="generateECodes_Required" onkeypress="return isNumberKey(event)">
</div>
所以我正在尝试这样的东西填充它:
Helem = IEMcAfee.Document.GetElementById("generateECodes_PackageDropdown")
Helem.SetAttribute("Value", "430")
Helem.RaiseEvent("onchange")
Helem = IEMcAfee.Document.GetElementById("generateECodes_TermDropdown")
If SA6.Checked Then
Helem.SetAttribute("Value", "5")
ElseIf SA12.Checked Then
Helem.SetAttribute("Value", "1")
ElseIf SA24.Checked Then
Helem.SetAttribute("Value", "2")
ElseIf SA36.Checked Then
Helem.SetAttribute("Value", "3")
End If
End If
Helem.RaiseEvent("onchange")
Helem = IEMcAfee.Document.GetElementById("generateECodes_Languages")
Helem.SetAttribute("Value", "29")
Helem.RaiseEvent("onchange")
Helem = IEMcAfee.Document.GetElementById("generateECodes_StoreNumber")
Helem.SetAttribute("Value", "230")
Helem.RaiseEvent("onchange")
Helem = IEMcAfee.Document.GetElementById("generateECodes_Required")
Helem.InnerText = "1"
IEMcAfee.Document.GetElementById("generateECodes_Button").Focus()
Helem = IEMcAfee.Document.GetElementById("generateECodes_Button")
Helem.InvokeMember("click")
我尝试使用RaiseEvent
更改InvokeMember
,我尝试将onchange
更改为我能想到的任何内容。
非常感谢任何帮助。