与vba& InternetExplorer.Application重新计算jquery表单 [英] Fire event with vba & InternetExplorer.Application to recalculate jquery form

查看:119
本文介绍了与vba& InternetExplorer.Application重新计算jquery表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从不同的网站收集数据。因此,我正在使用excel vba并启动Internet Explorer。我可以填写正常的表格。但有时我必须用后面的jquery脚本填写动态表单。

I'm trying to gather data from different websites. Therefore i'm using excel vba and start an internet explorer. I'm able to fill out a normal form. But sometimes i have to fill out a dynamic form with a jquery script behind.

如果填写前2个字段并触发事件,表单将仅启用所有输入字段(下拉菜单)。

The form will only enable all input fields (drop down menus), if the first 2 fields are filled out and an event is fired.

所以我的脚本可以填写表格,但不能解雇所需的重新计算事件。

So my script is able to fill out the form but not to fire the "recalculation" event which is needed.

如果您使用鼠标手动填写表格,则可以使用。我如何模拟这个事件?

If you fill out the form manually with your mouse it works. How can i simulate this event?

这是我的excel vba脚本:

This is my excel vba script:

Sub test_fill_form()

Dim url1 As String
Dim url2 As String
Dim url3 As String

url1 = "https://auto."
url2 = "ar"
url3 = "do.ch/selling/?step=1&uniqueid=8a7d2327-f426-4df7-8291-d6b55fc62e3c"

Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")

ie.Visible = True
apiShowWindow ie.hwnd, SW_MAXIMIZE
ie.navigate url1 & "ric" & url2 & url3

While ie.readyState <> 4: DoEvents: Wend

ie.document.all("Article_ArticleDetails_AutoRegistrationMonth").Click
ie.document.getElementById("Article_ArticleDetails_AutoRegistrationMonth").value = "1"
ie.document.getElementById("Article_ArticleDetails_AutoRegistrationYear").value = "2013"
End Sub


推荐答案

感谢您的帮助

现在我有解决方案:

ie.Document.getElementById("Article__").Click
ie.Document.getElementById("Article_ArticleDetails_").Focus
ie.Document.getElementById("Article_ArticleDetails_").Value = "9"

'This will run the java script / fire the recalc event
ie.Document.parentWindow.execScript "registrationUpdate()", "JavaScript"

全部谢谢。

这篇关于与vba&amp; InternetExplorer.Application重新计算jquery表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆