Function Reference

_IEFormElementSetValue

Set the value of a specified Form Element.

#include <IE.au3>
_IEFormElementSetValue ( ByRef $o_object, $s_newvalue [, $f_fireEvent = 1] )

 

Parameters

$o_object Object variable of an InternetExplorer.Application, Form Element object
$s_newvalue The new value to be set into the Form Element
$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: 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
@Extended: Contains invalid parameter number

 

Remarks

While all Form Elements have a value, only text oriented elements use their value attribute in an obvious fashion (type text, textarea, hidden, password and file). The value of other form elements does not affect what is displayed in the user interface, but rather the value that is returned by the element when it is selected or activated.

See _IEFormElementOptionSelect, _IEFormElementCheckboxSelect, _IEFormElementRadioSelect and _IEFormImageClick for more information.

 

Related

_IEFormElementGetValue, _IEFormElementGetCollection, _IEFormElementGetObjByName, _IEFormElementOptionSelect, _IEFormElementCheckboxSelect, _IEFormElementRadioSelect

 

Example


; *******************************************************
; Example 1 - Open a browser with the form example, set the value of a text form element
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oText = _IEFormElementGetObjByName ($oForm, "textExample")
_IEFormElementSetValue ($oText, "Hey! This works!")

; *******************************************************
; Example 2 - Get a reference to a specific form element and set its value.
;               In this case, submit a query to the Google search engine
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)

; *******************************************************
; Example 3 - Login to Hotmail
; *******************************************************
;
#include <IE.au3>
; Create a browser window and navigate to hotmail
$oIE = _IECreate ("http://www.hotmail.com")

; get pointers to the login form and username, password and signin fields
$o_form = _IEFormGetObjByName ($oIE, "f1")
$o_login = _IEFormElementGetObjByName ($o_form, "login")
$o_password = _IEFormElementGetObjByName ($o_form, "passwd")
$o_signin = _IEFormElementGetObjByName ($o_form, "SI")

$username = "your username here"
$password = "your password here"

; Set field values and submit the form
_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEAction ($o_signin, "click")