Jump to content

Selecting Select Form Element Choices


Recommended Posts

Is there an alternate way for me to select a choice from a dropdown SELECT form element?

$o_form = _IEFormGetObjByName($oIE, "form")
$select = _IEFormElementGetObjByName($o_form, "dropdownmenu")
_IEFormElementSetValue($select, 2)

Content changes based on the choice of the pulldown menu, but using _IEFormElementSetValue() doesn't seem to register with it. Any ideas? (Other than clicking on it, in which case I'd just write my whole script with pixel detection and whatnot... trying to keep the window in the background/minimized/etc)

Link to comment
Share on other sites

  • Moderators

Is there an alternate way for me to select a choice from a dropdown SELECT form element?

$o_form = _IEFormGetObjByName($oIE, "form")
$select = _IEFormElementGetObjByName($o_form, "dropdownmenu")
_IEFormElementSetValue($select, 2)

Content changes based on the choice of the pulldown menu, but using _IEFormElementSetValue() doesn't seem to register with it. Any ideas? (Other than clicking on it, in which case I'd just write my whole script with pixel detection and whatnot... trying to keep the window in the background/minimized/etc)

; $i_index is the 0-based index of the option you wish to select 
$select.options ($i_index).selected = True
Link to comment
Share on other sites

  • Moderators

Thanks. However, that also doesn't seem to work. But thank you for the fast reply.

To prove the concept try this script:

#include <IE.au3>

$oIE = _IECreate()
_IENavigate($oIE, "http://www.quadryders.com/test/select_test.html")

$oForm = _IEFormGetObjByName($oIE, "testform")
$oSelect = _IEFormElementGetObjByName($oForm, "abcselect")

For $i = 0 To 3
    $oSelect.options ($i).selected = True
    Sleep(1000)
Next
Link to comment
Share on other sites

OK, then you need to add this...

$select.options ($i_index).fireEvent("onchange")

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I get an error "The requestion action with this object has failed." The error is pointing at the line that Dale gave me.

Also, a note: it's a dropdown menu, not the one shown in big_daddy's example. I called it select, cause that's what the element type came up as. Sorry for any confusion.

I'll be gone for an hour or two, but thanks for the replies.

Link to comment
Share on other sites

take a look at the page source... I think you'll see something with an onchange event handler specified.

thinking about it, it is probably on the dropdown element instead of on the item

that is where you want to fire the event.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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