↑  ←  Описание функции


_IEFormElementOptionSelect

Set the value of a specified form element.

#include <IE.au3>
_IEFormElementOptionSelect(ByRef $o_object, $s_string [, $f_select = 1 [, $s_mode = "byValue" [, $f_fireEvent = 1]]])

Параметры

$o_object Form Element Object of type "Select Option"
$s_string Value used to match element - treatment based on $s_mode
$f_select [необязательный] specifies whether element should be selected or deselected
-1 = Return selected state
0 = Deselect the element
1 = (по умолчанию) Select the element
$s_mode [необязательный] specifies search mode
byValue = (по умолчанию) value of the option you wish to select
byText = text of the option you wish to select
byIndex = 0-based index of option you wish to select
$f_fireEvent [необязательный] specifies whether to fire OnChange and OnClick events after changing value
0 = do not fire OnChange or OnClick event after setting value
1 = (по умолчанию) fire OnChange and OnClick events after setting value

Возвращаемое значение

Успех:If $f_select = -1, returns the current selected state, else returns 1
Ошибка:Возвращает 0 и устанавливает @error
@error:0 ($_IEStatus_Success) = Нет ошибок
3 ($_IEStatus_InvalidDataType) = Неверный тип данных
4 ($_IEStatus_InvalidObjectType) = Неверный тип объекта
5 ($_IEStatus_InvalidValue) = Неверное значение
7 ($_IEStatus_NoMatch) = Нет совпадений
@extended:Содержит номер неверного параметра

Примечания

The $f_fireEvent parameter is significant only if the form element has an onChange event associated with it.

См. также

_IEFormElementCheckBoxSelect, _IEFormElementRadioSelect, _IEFormElementGetValue, _IEFormElementSetValue

Пример

; *******************************************************
; Пример 1 - Open a browser with the form example, get reference to form, get reference
;               to select element, cycle 10 times selecting options byValue, byText and byIndex
;               Note: You will likely need to scroll down on the page to see the changes
; *******************************************************

#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName ($oForm, "selectExample")
For $i = 1 To 10
    _IEFormElementOptionSelect ($oSelect, "Freepage", 1, "byText")
    Sleep(1000)
    _IEFormElementOptionSelect ($oSelect, "midipage.html", 1, "byValue")
    Sleep(1000)
    _IEFormElementOptionSelect ($oSelect, 0, 1, "byIndex")
    Sleep(1000)
Next

; *******************************************************
; Пример 2 - Open a browser with the form example, get reference to form, get reference
;               to select multiple element, cycle 5 times selecting and then deselecting
;               options byValue, byText and byIndex.
;               Note: You will likely need to scroll down on the page to see the changes
; *******************************************************

#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName ($oForm, "multipleSelectExample")
For $i = 1 To 5
    _IEFormElementOptionSelect ($oSelect, "Carlos", 1, "byText")
    Sleep(1000)
    _IEFormElementOptionSelect ($oSelect, "Name2", 1, "byValue")
    Sleep(1000)
    _IEFormElementOptionSelect ($oSelect, 5, 1, "byIndex")
    Sleep(1000)
    _IEFormElementOptionSelect ($oSelect, "Carlos", 0, "byText")
    Sleep(1000)
    _IEFormElementOptionSelect ($oSelect, "Name2", 0, "byValue")
    Sleep(1000)
    _IEFormElementOptionSelect ($oSelect, 5, 0, "byIndex")
    Sleep(1000)
Next

; *******************************************************
; Пример 3 - Open a browser with the form example, get reference to form, get reference
;               to select element, check to see if the option "Freepage" is selected and
;               report result.  Repeat for the option with index 0 and for the option
;               with value of 'midipage.html'
;               Note: You will likely need to scroll down on the page to see the changes
; *******************************************************

#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName ($oForm, "selectExample")
If _IEFormElementOptionSelect ($oSelect, "Freepage", -1, "byText") Then
    MsgBox(4096, "Option Selected", "Option Freepage is selected")
Else
    MsgBox(4096, "Option Selected", "Option Freepage is Not selected")
EndIf
If _IEFormElementOptionSelect ($oSelect, 0, -1, "byIndex") Then
    MsgBox(4096, "Option Selected", "The First (index 0) option is selected")
Else
    MsgBox(4096, "Option Selected", "The First (index 0) option is Not selected")
EndIf
If _IEFormElementOptionSelect ($oSelect, "midipage.html", -1, "byValue") Then
    MsgBox(4096, "Option Selected", "The option with value 'midipage.html' is selected")
Else
    MsgBox(4096, "Option Selected", "The option with value 'midipage.html' is NOT selected")
EndIf