Jump to content

[SOLVED] Number of options in IE dropdown


Recommended Posts

Hi!

I've searched for an answer to this simple question for a couple of hours now, and it's driving me crazy.

On a web page, there's a dropdown box.

I want to know the number of options that are in the box. How do I get that value?

I've tried this:

CODE

$oForm = _IEFormGetObjByName ($oIE, "engagementForm") ; Name of form

$oSelect = _IEFormElementGetObjByName ($oForm, "engagementNumber") ; Name of dropdown box

_IEFormElementGetCollection ($oSelect)

$oOptions = @extended

MsgBox(0, "Info", "There are " & $oOptions & " options in the box")

but it just returns 1.

Am I using the wrong function or what is the matter?

I'm sure it's quite easy, but I just can't see it. Please help!

Edited by Ohrstrom
Link to comment
Share on other sites

Hi!

I've searched for an answer to this simple question for a couple of hours now, and it's driving me crazy.

On a web page, there's a dropdown box.

I want to know the number of options that are in the box. How do I get that value?

I've tried this:

$oForm = _IEFormGetObjByName ($oIE, "engagementForm"); Name of form
$oSelect = _IEFormElementGetObjByName ($oForm, "engagementNumber"); Name of dropdown box
    _IEFormElementGetCollection ($oSelect)
$oOptions = @extended
MsgBox(0, "Info", "There are " & $oOptions & " options in the box")

but it just returns 1.

Am I using the wrong function or what is the matter?

I'm sure it's quite easy, but I just can't see it. Please help!

Try $oSelect.length:
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName ($oForm, "selectExample")
$iOptionCount = $oSelect.length
ConsoleWrite("Length = " & $iOptionCount & @LF)
For $i = 1 To 10
    For $n = 0 To $iOptionCount - 1
        _IEFormElementOptionselect ($oSelect, $n, 1, "byIndex")
        Sleep(1000)
    Next
Next

:P

Edit: Improved demo.

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
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...