VBA / HTML / jQuery的自动完成选上 - 在列表中选择 [英] VBA / HTML / jQuery Chosen AutoComplete - Select in a list

查看:696
本文介绍了VBA / HTML / jQuery的自动完成选上 - 在列表中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Excel中使用VBA在网站上在列表中选择一个值。
这不是一个正常的名单,该网站使用jQuery选择了自动完成(像这样:例如)。
它看起来像这样:
截图

I'm trying to select a value in a list on a website using VBA in Excel. It's not a "normal list", the website is using jQuery Chosen auto-complete (like this : example ). It looks like this : screenshot .

我试过很多东西(像往常一样列出),但只的SendKeys工作,我想用更好的方法。

I tried a lot of things (like for usual lists), but only SendKeys worked and I would like to use a better method.

我看到HTML code,它chosen.jquery.js在页面上使用的头的部分。

I saw on the "head" part of the HTML code that chosen.jquery.js is used on the page.

下面是盒子的HTML code:

Here is the HTML code of the box :

<select name="type" id="type" class="texteFormulaire" style="width:600px;  " onblur="" onmousedown="" onclick="" onchange=""  >
<option value="0">---</option>
<option value="1">blabla</option>
<option value="2">blublu</option>
</select>
<script> 
  autoCompleteSelect.activerAutoCompletePourSelect("type");
</script>

如果您有任何想法,非常感谢!
我不知道如果我把你可能需要,请不要犹豫,问我要更多信息的所有信息。

If you have any idea, thanks a lot ! I don't know if I put all the information you may need, please don't hesitate to ask me for further informations.

推荐答案

好了,我终于找到了答案。
也许这将帮助别人:

Well, I finally found an answer. Maybe it will help others :

Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = IE.document.parentWindow
Call CurrentWindow.execScript("jQuery('#type').val('2');jQuery('#type').trigger('chosen:updated');")

这篇关于VBA / HTML / jQuery的自动完成选上 - 在列表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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