Jump to content
Sign in to follow this  

Getting the text inside <option> tags using IE.au3 functions

Recommended Posts


I need to use IE.au3 functions to get the actual text inside the <option> tags of a dropdown.

So far, I can only get the value by using the following code. Unfortunately, the value does not equal the text that I need.

$oForm = _IEFormGetObjByName ($oIE, "routeListTwoForm" )
$oForm_dropdown = _IEFormElementGetObjByName ($oForm, "fkcallmanagergroup")
$oFormText = _IEFormElementGetValue ($oForm_dropdown)

This will return the value of the <option> tag, but it is just a long string of random characters. What I need is the text.

<option value=aasdlfkjoaienfioaosviohiasdoijhv>I need this text.</option>

Thanks in advance for any help you can provide!

Share this post

Link to post
Share on other sites

If it's a selection group with options under it, you don't want the value property of the selection, you want the innerText of the option index that is currently selected:

#include <IE.au3>

$oIE = _IE_Example("form")
$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName($oForm, "selectExample")
_IEFormElementOptionselect($oSelect, "midipage.html", 1, "byValue")
$iSelIndex = $oSelect.selectedIndex
$oOption = _IETagNameGetCollection($oSelect, "option", $iSelIndex)
$sSelText = $oOption.innerText

ConsoleWrite("Index selected = " & $iSelIndex & "; text = " & $sSelText & @LF)


Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

That worked great! Thanks!

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