Sign in to follow this  
Followers 0
Queener

IE radio select array

3 posts in this topic

#1 ·  Posted (edited)

This is my code

$oDoc = _IEDocGetObj($oIE)
$oArray = $oDoc.getElementsByTagName("input")
For $element In $oArray
    If $element.ID = "optAddressChange2" Then
        _IEAction($element, "click")
        sleep(2000)
    EndIf

The code works. Just want to know if there's a better way to select multiple radio in an array instead of using if statement all the way for it to select radios.

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you could take note of the index of your target radio, and next time use directly the index to fire the target radio:
for example
first time find the index in a way like this:

$oDoc = _IEDocGetObj($oIE)
; $oArray = $oDoc.getElementsByTagName("input")
$oArray = _IETagNameGetCollection($oIE, "input")
Local $nIndex = 0
For $element In $oArray
    If $element.ID = "optAddressChange2" Then
        ; _IEAction($element, "click")
        ConsoleWrite("The index of the wanted radio is " & $nIndex & @CRLF) ; this will tell you the index
        ; Sleep(2000)
        $nIndex += 1
    EndIf
Next

and next time, supposing that the target element is the nr. 5,  modify your code in something like this:

$oElement = _IETagNameGetCollection($oIE, "input", 5) ; this suppose the target element is the nr. 5
_IEAction($oElement, "click")

I hope this can help you

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

I used case statement and it worked out great. Thanks for your useful info; will be using it in the future.


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0