的形式.使用VBA时提交不通过
Form.Submit does not go through when using VBA
我有一个网页,我从中提取数据。我可以做一切与VBA除了点击一个图像元素,然后提交一个表单和一个弹出的数据被创建。
image元素中的一个属性名为"productguid",其字符串值=
" a12 - 545"。
在我用鼠标点击image元素之前,表单的HTML代码如下:
<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
<input type="hidden" name="ProductGuid" value="">
</form>
这是我用鼠标手动点击后的HTML代码:
<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
<input type="hidden" name="ProductGuid" value="a12-545">
</form>
基于此,我假设来自image元素的productguid值在提交之前被传递到表单上。这是我的VBA代码看起来像这样:
'Change the input element value
ie.Document.getElementById("GetProductQuantitiesForAccessibleBranches").all.item(0).value = "a12-545"
'Submit the form
ie.Document.getElementyId("GetProductQuantitiesForAccessibleBranches").Submit
根据Locals窗口,所有Javascript事件都是Null
。这两行代码运行没有任何错误,但网页不更新。我遗漏了什么吗?
我也试过用.Click
方法点击图像元素,但这也不做任何事情。
这个网页有密码保护,所以我不能公开发布URL。
更新:
这是标签中的HTML,通常是手动点击,然后提交表单。也许这里面有什么我能用的?
<img alt="View Quantities At Other Locations" src="/WebOrder/Images/CheckQtys.gif"
title="View Quantities At Other Locations" class="popup"
popupdirection="upperleft" popupwidth="380"
popupcontent="#ProductQuantitiesForAccessibleBranches"
onbeforepopupcreate="onBeforePopupCreate_GetProductQuantitiesForAccessibleBranches(this)"
popupajaxformid="GetProductQuantitiesForAccessibleBranches"
onbeforepopupajaxpost="onBeforePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)"
oncompletepopupajaxpost="onCompletePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)"
productguid="a12-545"
displayitem="33902"
brandguid="00000000-0000-0000-0000-000000000000"
brandname="" brandsku="">
给这个机会,我怀疑这将是一个"完美"的答案,没有实际看到的网站。然而,这应该找到正确的图像标签,假设你没有任何框架/iframe(请检查有没有),和应该点击它。
Public Sub Click_IMG_Tag()
Dim Elements As Object
Dim Element As Object
'Get a pointer to IE etc first, I'm assuming this is already done
Set Elements = IE.Document.getElementsByTagName("img")
For Each Element In Elements
On Error Resume Next ' used to bypass elements that don't have .Title property
' later, you should error handle this exception
If Element.Title = "View Quantities At Other Locations" Then
Element.Focus
Element.Click
Element.FireEvent ("OnClick")
IELoad IE
Exit For
End If
Next
End Sub
Public Sub IELoad(Browser As Object)
While Browser.busy Or Browser.Readystate <> 4
Application.Wait (Now() + TimeValue("00:00:01"))
DoEvents
Wend
End Sub
相关文章:
- Javascript生成的表单未提交
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- HTML表单提交时未执行外部函数
- 在POST中将html表作为csv提交
- 我应该使用Ng提交还是点击表格
- 我想使用模态通过php文件发送邮件,并且我希望在提交关闭后关闭pop
- 提交后保留下拉选择的值
- 键入最后一位数字后自动提交
- 阻止表单元素提交
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- Jquery提交表单而不刷新
- 将图像上传ajax与表单提交ajax相结合
- Jquery表单验证插件-如果选中复选框,如何在提交时执行某些操作
- 自定义表单验证和提交
- 带有验证和隐藏字段值的提交按钮
- 如何在 API 调用后和 if 语句中启用提交按钮
- Jquery函数在错误的时间提交
- Javascript无法处理表单提交
- 提交按钮,该按钮位于使用 Excel VBA 的 Javascript 中
- 的形式.使用VBA时提交不通过