491623644 发表于 2013-1-8 15:17:47

【已解决】AU3怎么实现点击JS页面选择框

本帖最后由 491623644 于 2013-1-9 09:40 编辑

<h3>步骤2:选择送货地址</h3></div><div class="pbSubsection"><table class="detailList" border="0" cellpadding="0" cellspacing="0"><tr><td class="data2Colfirst " colSpan="2"><table class="list " id="j_id0:j_id2:pb:address:Address" border="0" cellpadding="0" cellspacing="0"><colgroup span="10"></colgroup><thead class="rich-table-thead"><tr class="headerRow "><th class="headerRow" scope="col" colspan="1" id="j_id0:j_id2:pb:address:Address:colSelectheader"><div id="j_id0:j_id2:pb:address:Address:colSelectheader:sortDiv">选择</div></th><th class="headerRow" scope="col" colspan="1" id="j_id0:j_id2:pb:address:Address:j_id34header"><div id="j_id0:j_id2:pb:address:Address:j_id34header:sortDiv">城市名称</div></th><th class="headerRow" scope="col" colspan="1" id="j_id0:j_id2:pb:address:Address:j_id35header"><div id="j_id0:j_id2:pb:address:Address:j_id35header:sortDiv">送货地址代码</div></th><th class="headerRow" scope="col" colspan="1" id="j_id0:j_id2:pb:address:Address:j_id36header"><div id="j_id0:j_id2:pb:address:Address:j_id36header:sortDiv">地址</div></th></tr></thead><tbody id="j_id0:j_id2:pb:address:Address:tb"><tr class="dataRow evenfirst " onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onBlur="if (window.hiOff){hiOff(this);}" onFocus="if (window.hiOn){hiOn(this);}"><td class="dataCell" id="j_id0:j_id2:pb:address:Address:0:colSelect" colspan="1" width="1px"><input id="j_id0:j_id2:pb:address:Address:0:chkSelect" type="checkbox" name="j_id0:j_id2:pb:address:Address:0:chkSelect" onchange="A4J.AJAX.Submit('j_id0:j_id2',event,{'similarityGroupingId':'j_id0:j_id2:pb:address:Address:0:j_id33','parameters':{'j_id0:j_id2:pb:address:Address:0:j_id33':'j_id0:j_id2:pb:address:Address:0:j_id33'} } )" /></td><td class="dataCell" id="j_id0:j_id2:pb:address:Address:0:j_id34" colspan="1">泸州</td><td class="dataCell" id="j_id0:j_id2:pb:address:Address:0:j_id35" colspan="1">1123988</td><td class="dataCell" id="j_id0:j_id2:pb:address:Address:0:j_id36" colspan="1">泸州市杜家街紫荆苑A幢</td></tr><tr class=" dataRow odd " onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onBlur="if (window.hiOff){hiOff(this);}" onFocus="if (window.hiOn){hiOn(this);}"><td class="dataCell" id="j_id0:j_id2:pb:address:Address:1:colSelect" colspan="1" width="1px">HTML代码如上所示,其中有一句:input id="j_id0:j_id2:pb:address:Address:0:chkSelect" type="checkbox" name="j_id0:j_id2:pb:address:Address:0:chkSelect" 为一个选择框,需要点击该选择框,使用autoit应该怎么去操作?谢谢!

491623644 发表于 2013-1-8 15:19:23

本帖最后由 491623644 于 2013-1-8 15:20 编辑

Func js($script)
        $oIE.document.parentWindow.execscript($script)
EndFunc
js(FileRead("jquery-1.6.1.min.js"))
        js("$('#j_id0:j_id2:pb:address:Address:0:chkSelect').click()")使用这种方法的时候,系统运行没有反应(选择框没有勾选),请各位指点!

komaau3 发表于 2013-1-8 16:01:34

type="checkbox" 你去点击可定不行啊
$oItem = _IEGetObjById($oIE, "j_id0:j_id2:pb:address:Address:0:chkSelect")
$oItem.checked = True
$oItem.fireEvent("onChange")
$oItem.fireEvent("OnClick")

annybaby 发表于 2013-1-8 16:04:34

回复 2# 491623644

几乎可以肯定是里面冒号引起的问题(你的Js代码没错,将其中的冒号去掉就可以),因为通过AU3来调用jQuery的话,有可能会在处理多个双引号及":"等出现些问题,建议直接使用IEUDF或者风行者坛友的网页快捕

491623644 发表于 2013-1-8 17:38:25

回复 3# komaau3
直接用IEGetObjById是不能获取到ID的吧?

annybaby 发表于 2013-1-8 22:38:03

回复 3# komaau3

方法不错,不过应该不是这个原因,直接使用_IE**函数,用click是可以的,楼主用了jQuery,但jQuery里好像没有FireEvent(好像是用另外的事件触发方式了,不太熟)
原因应该是JQ在处理单双引号及":"时出问题了删除了冒号离线测试可行~~

annybaby 发表于 2013-1-8 22:48:32

真想不到,还有求助也审核的~~开眼界了

491623644 发表于 2013-1-8 22:53:40

回复 4# annybaby


    谢谢!已使用网页快捕,很好用!

haijie1223 发表于 2013-1-8 23:44:37

遍历控件,得到你想要的控件;或者直接从源码中查找控件id。

破帽遮颜 发表于 2013-1-9 02:25:47

学习了~~~~~~~~

破帽遮颜 发表于 2013-1-9 02:26:26

网页快捕,我也去下载一个试试
页: [1]
查看完整版本: 【已解决】AU3怎么实现点击JS页面选择框