sammy1983 Posted April 28, 2016 Posted April 28, 2016 Hi Peers, I am kinda stuck with a problem. My webpage has 2 buttons with similar attributes as shown below but with different 'Onclick' events. The two buttons are placed one on the other and I want to invoke Onclick event for the second button. Button 1: <input type="button" onclick="javascript:callDummy(hid_8296_query1, hid_8296_query2, lis_8296_fname_lis_0_1_y_8296, hid_8296_orderby, hid_8296_criteria, hid_8296_seltype,fnv_8296_fname_fnv_0);" alt="List" value="List >>" class="listButton" name="btnList" tabindex="300"> Button 2: <input type="button" onclick="javascript:callDummy(hid_6770_query1, hid_6770_query2, lis_6770_fname_lis_0_0_0_0, hid_6770_orderby, hid_6770_criteria, hid_6770_seltype,fnv_6770_fname_fnv_0);" alt="List" value="List >>" class="listButton" name="btnList" tabindex="300"> Here is my code which triggers the 1st button but not the 2nd one. $oButton = _IEGetObjByName($oIE, 'btnList') $oButton.fireEvent("onclick") Can someone help plz? Thanks.
MichaelHB Posted April 28, 2016 Posted April 28, 2016 Try this @sammy1983 Local $oButton2 = $oIE.document.GetElementsByName("btnList") If Not IsObj($oButton2) Then Exit ConsoleWrite("Error in $oButton2" & @CRLF) $oButton2.Item(1).fireEvent("onclick") Or: $oButton2 = _IEGetObjByName($oIE, 'btnList', 1) $oButton2.fireEvent("onclick")
sammy1983 Posted April 28, 2016 Author Posted April 28, 2016 Hey MichaelHB, Was waiting for you. And once again you nailed it. 2nd method worked. On a separate note, even I fixed the issue with the below code but yours I jus love it. Now using your method. Thanks again. $oLinks = _IETagNameGetCollection($oIE, "input") For $oLink In $oLinks If String($oLink.name) = "btnList" Then _IEAction($oLink, "click") EndIf Next
MichaelHB Posted April 28, 2016 Posted April 28, 2016 Glad to help. This information was in the helpfile: Spoiler Parameters $oObject Object variable of an InternetExplorer.Application, Window or Frame object $sName Specifies name of the object you wish to match $iIndex [optional] If name occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified objects
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now