Jump to content

Recommended Posts

Hi All, 

I have a question related to _IEFormElementOptionSelect in the reference file. This drop down contains three items; Homepage, Midipage, Freepage. 

How can I get the name of these items? If I use .innertext, in another drop down list contains spaces, so I cannot split them. 

; Open a browser with the form example, get reference to form, get reference
; to select element, cycle 10 times selecting options byValue, byText and byIndex

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample")
_IEAction($oSelect, "focus")
For $i = 1 To 10
    _IEFormElementOptionSelect($oSelect, "Freepage", 1, "byText")
    Sleep(10)
    _IEFormElementOptionSelect($oSelect, "midipage.html", 1, "byValue")
    Sleep(10)
    _IEFormElementOptionSelect($oSelect, 0, 1, "byIndex")
    Sleep(10)
Next

_IEQuit($oIE)

;== Question ==
$aItems = StringSplit($oSelect.innerText, " ")
For $i = 1 To $aItems[0] - 1
    ConsoleWrite("Item-" & $i & ": " & $aItems[$i] & @CRLF)
Next

 

Edited by taylansan
Modified the title as solved

TY.

Link to comment
Share on other sites

Wasn't 100% sure what you were after maybe something like this?

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample")

_IEFormElementOptionSelect($oSelect, "Freepage", 1, "byText")
    ConsoleWrite("Selected: " & _IEFormElementGetValue($oSelect) & @CRLF)

Local $oOptions = _IETagNameGetCollection($oSelect, "Option")
For $oOption In $oOptions
    ConsoleWrite($oOption.InnerText & @CRLF)
Next

 

Link to comment
Share on other sites

Here's one way --

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample")

Local $oOptions = _IETagNameGetCollection($oSelect, 'option')

For $oOption In $oOptions
    ConsoleWrite("Option: " & $oOption.value & @CRLF)
    ConsoleWrite("Option: " & $oOption.innertext & @CRLF)
Next

 

Link to comment
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
 Share

×
×
  • Create New...