Jump to content
Sign in to follow this  
Ohrstrom

[SOLVED] Number of options in IE dropdown

Recommended Posts

Ohrstrom

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
Ohrstrom

Wohoo!

That sure helped. Thanks a lot! =)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.