Function Reference

_IEFormElementRadioSelect

Set the value of a specified form element.

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

 

Parameters

$o_object Object variable of an InternetExplorer.Application, Form object
$s_string Value used to match element - treatment based on $s_mode
$s_name Name or Id of Radio Group
$f_select Optional: specifies whether element should be selected or deselected
-1 = Return selected state
0 = Unselect the element
1 = (Default) Select the element
$s_mode Optional: specifies search mode
byValue = (Default) value of the radio you wish to select
byIndex = 0-based index of radio you wish to select
$f_fireEvent Optional: specifies whether to fire an OnChange event after changing value
0 = do not fire OnChange event after setting value
1 = (Default) fire OnChange event after setting value

 

Return Value

Success: If $f_select = -1, returns the current selected state, else returns 1
Failure: Returns 0 and sets @ERROR
@Error: 0 ($_IEStatus_Success) = No Error
3 ($_IEStatus_InvalidDataType) = Invalid Data Type
4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
5 ($_IEStatus_InvalidValue) = Invalid Value
7 ($_IEStatus_NoMatch) = No Match
@Extended: Contains invalid parameter number

 

Remarks

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

$s_Name is a mandatory parameter for this function. Radio buttons are operated upon in groups sharing the same name. No more than one element within a group may be selected at a given time - when one item is selected, all others are deselected.

 

Related

_IEFormElementOptionSelect, _IEFormElementCheckBoxSelect

 

Example


; *******************************************************
; Example 1 - Open a browser with the form example, get reference to form, select
;               each radio button byValue, then deselect the last item leaving none selected.
;               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")
For $i = 1 To 5
    _IEFormElementRadioSelect ($oForm, "vehicleAirplane", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, "vehicleTrain", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, "vehicleBoat", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, "vehicleCar", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, "vehicleCar", "radioExample", 0, "byValue")
    Sleep(1000)
Next

; *******************************************************
; Example 2 - Open a browser with the form example, get reference to form, select
;               each radio button byIndex, then deselect the last item leaving none selected.
;               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")
For $i = 1 To 5
    _IEFormElementRadioSelect ($oForm, 3, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, 2, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, 1, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, 0, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect ($oForm, 0, "radioExample", 0, "byIndex")
    Sleep(1000)
Next