Sign in to follow this  
Followers 0
diikee

<option selected>

5 posts in this topic

<SELECT id=OidSB1.2.3 onchange=setEcam(this) name=OidSB1.2.3>

<OPTION>xlow<OPTION>low<OPTION selected>medium<OPTION>high</OPTION>

</SELECT>

$oForm = _IEFormGetObjByName ($oIE, "myform")
$sh = _IEFormElementGetObjByName ($oForm, "OidSB1.2.3")
For $s In $sh
    $sopt = _IETagNameGetCollection($sh, "OPTION")
        For $sop in $sopt 
                ConsoleWrite($sop.selected & @CRLF)
            Sleep(2000)
            $o = $sop.innerText --->>>>this prints the options name
                
                ConsoleWrite($o & @CRLF)
            _IEFormElementOptionselect($sh, $o, 1, "byText")
                    ConsoleWrite($sopt.selected & @CRLF)------->>>>Prints a 0 instead of the selected option
            Sleep(1000)
        Next
    ExitLoop
Next

Shouldn't it print "medium"??? instead of 0's

Share this post


Link to post
Share on other sites



Don't think so. I'm not sure about AutoIt but when using Javascript the proper way to get the text of a selected option is to first get the select element's selectedIndex property, then use that to determine which option in the select to check the text from. Something like the following:

(Javascript, not AutoIt code)
selectObject = document.formName.selectName
index = selectObject.selectedIndex
selectedText = selectObject[index].text

Share this post


Link to post
Share on other sites

Can I incorporate the java code into autoit script??

Share this post


Link to post
Share on other sites

I dunno, maybe. You'd be better off just figuring out how it works in AutoIt though, I imagine it's not a whole lot different.

Share this post


Link to post
Share on other sites

In your example, $sopt is a Tagname Collection rather than an Options Collection. You need to get the Options collection... these should help you:

$sh.options.selectedIndex

$sh.options.selectedIndex.text

$sh.options.selectedIndex.value

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

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