如何刷新“表单元素”当它通过网络浏览器控件更改时?

发布于 2024-12-07 10:10:03 字数 841 浏览 5 评论 0原文

我正在使用 VB6(是的,我知道它已经有 10 年历史了:),但它可以工作)。 VB.NET 答案也可能有效,所以如果您知道答案,也请回答!

我正在“手动”在表单中设置下拉框,但“网络浏览器”似乎没有更新。

这是一个示例

如果您注意到表格中有一个地方要求您填写状态。 (即加利福尼亚州等)。它看起来像 MSIE 中的 javascript/DHTML 弹出框(firefox 不这样做,因此您需要使用 MSIE,因为这是 Web 浏览器控件所依赖的)。如果我“单击”“状态”字段,则会出现一个弹出框。然后我可以说选择“CA”代表加利福尼亚州,它会更新它。 (现在显示“CA”)。

如果我以编程方式执行此操作,我会执行以下操作:

WebBrowser1.forms(2).elements(13).value = "CA" ' (sets it to 'california')
WebBrowser1.forms(2).elements(13).item(9).selected = true (makes sure it is 'selected')

但是 - 在网络浏览器控件内 - 它仍然看起来好像什么都没有改变。 (实际上它有,即,如果我提交表单,它将提交正确的信息),但它只是不“更新”它。

您是否知道我如何执行“强制”刷新(以编程方式或通过某些 javascript/dhtml 刷新),然后正确地“更新”字段以显示已选择“CA”?

非常感谢!

I am using VB6 (yes, I know it's 10 years old :), but it works). VB.NET answers may work as well, so if you know the answer, please answer too!

I am "manually" setting a dropdown box in a form, yet the 'webbrowser' doesn't seem to update.

Here's an example

If you notice in the form, it has a place where it asks you to fill in a state. (I.e., california, etc). It looks like a javascript/DHTML popup box in MSIE (firefox doesn't do the same, so you need to use MSIE, since that is what the webbrowser control relies on). If I 'click' on the "state" field, a popup box appears. I then can say select "CA" for california, and it updates it. (It now says "CA").

If I progrmatically do it, I would do something like:

WebBrowser1.forms(2).elements(13).value = "CA" ' (sets it to 'california')
WebBrowser1.forms(2).elements(13).item(9).selected = true (makes sure it is 'selected')

However -- within the webbrowser control -- it still appears as if nothing has changed. (In reality it has, i.e., if I submit the form it will submit the correct info), but it just doesn't "update" it.

Do you have any idea how I can do a "forced" refresh (either progrmatically or through some javascript/dhtml refresh), that will correctly then 'update' the field to show that "CA" has been selected?

Thanks very much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2024-12-14 10:10:03

我使用的最后一个 VB 版本是 VB3,所以请原谅我的 VB 语法:)

如果更改事件有一个您想要模拟的处理程序

WebBrowser1.forms(2).elements(13).item(9).fireEvent ("onchange", WebBrowser1.Document.createEventObject())

The last VB version I used was VB3 so forgive my VB grammar :)

If the change event has a handler that you want to simulate

WebBrowser1.forms(2).elements(13).item(9).fireEvent ("onchange",WebBrowser1.Document.createEventObject())

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文