Javascript 在网站上使用html中的vba更新相关组合框
我在一个网站上有这个表单,它有一个独立的组合框 通过vba更新第一个组合框(状态)时,第二个组合框(市政)需要填充列表 我试过这样做:Javascript 在网站上使用html中的vba更新相关组合框,javascript,html,vba,excel,Javascript,Html,Vba,Excel,我在一个网站上有这个表单,它有一个独立的组合框 通过vba更新第一个组合框(状态)时,第二个组合框(市政)需要填充列表 我试过这样做: Set ie = New InternetExplorer ie.Visible = True ie.Navigate "http://www2.correios.com.br/sistemas/agencias/" Do Until (ie.ReadyState = 4) Loop 'First combobox
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "http://www2.correios.com.br/sistemas/agencias/"
Do Until (ie.ReadyState = 4)
Loop
'First combobox
ie.Document.all("estadoAgencia").Item(2).Selected = True
ie.Document.all("estadoAgencia").Item(2).Focus
ie.Document.all("estadoAgencia").Item(2).Click
ie.Document.all("estadoAgencia").Item(2).FireEvent ("onChange")
'Second combobox
ie.Document.all("municipioAgencia").Item(2).Selected = True 'Do not work here, this last line
我想我必须使用以下方法调用一些函数:
ie.Document.parentWindow.execScript(“functionname()”)
但是我在这行中找不到要调用的函数
<script type="text/javascript">/* <![CDATA[ */
var _cf_cfcAgencia=ColdFusion.AjaxProxy.init('/sistemas/agencias/cfc/cfcAgencia.cfc','ProxyAjax');
_cf_cfcAgencia.prototype.getAgenciasProximas=function(latitude,longitude) { return ColdFusion.AjaxProxy.invoke(this, "getAgenciasProximas","45A0BE8C97B5F00E", {latitude:latitude,longitude:longitude});};
_cf_cfcAgencia.prototype.getBairro=function(UF,municipio) { return ColdFusion.AjaxProxy.invoke(this, "getBairro","45A0BE8C97B5F00E", {UF:UF,municipio:municipio});};
_cf_cfcAgencia.prototype.getUF=function() { return ColdFusion.AjaxProxy.invoke(this, "getUF","45A0BE8C97B5F00E", {});};
_cf_cfcAgencia.prototype.getMunicipio=function(UF) { return ColdFusion.AjaxProxy.invoke(this, "getMunicipio","45A0BE8C97B5F00E", {UF:UF});};
/* ]]> */</script>
有人能帮我吗?我在IE8和更早版本上做了很多工作,但在IE9+上似乎有了一些变化。我们必须使用
dispatchEvent()
以不同的方式连接事件
完美!非常感谢你,吉米!令人惊叹的!如果你需要更多的帮助,请告诉我。如果这真的成功了,请将所有问题都解决了,谢谢!
_cf_cfcAgencia.prototype.getMunicipio=function(UF)
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "http://www2.correios.com.br/sistemas/agencias/"
Do Until (ie.ReadyState = 4)
Loop
'First combobox
' ie.document.all("estadoAgencia").Item(2).Selected = True
' ie.document.all("estadoAgencia").Item(2).Focus
' ie.document.all("estadoAgencia").Item(2).Click
' ie.document.all("estadoAgencia").Item(2).FireEvent ("onkeypress")
Set evt = ie.document.createevent("htmlevents")
evt.initevent "change", True, False
Set lst = ie.document.getelementbyid("estadoAgencia")
lst.selectedindex = 2 'select it as you were
lst.dispatchevent evt 'Fire the event with dispatchEvent
'Second combobox
ie.document.all("municipioAgencia").Item(2).Selected = True