ElementValueById
Interface AntViewDocument
Type: Property
Access: Write
Parameters: String Id String Value
Set the contents for the Value attribute of the html element identified by Id in the document currently loaded in the WebView2 component.
Note that the id is case sensitive and must match the case of the html element.
Not all of the html elements normally have a value attribute.
The most common element with a value attribute is the input element as used in html forms.
<form id="login" class="login" action="thankYou.html">
<div class="loginName">
<label for="username">UserName</label>
<input type="text" id="username" placeholder="User Name" required />
</div>
<div class="loginPassword">
<label for="password">Password</label>
<input type="password" id="password" placeholder="Password" required />
</div>
<div class="loginBtn">
<button id="submit" type="submit" name="submit">Login</button>
</div>
</form>
Setting this property triggers the OnSetElementValueById event on completion as it is an asynchronous operation.
Example in DataFlex:
Object oFillFieldsButton is a Button
Set Location to 199 40
Set Label to "Fill Fields"
Set peAnchors to anBottomLeft
Procedure OnClick
Send ConnectBrowser to oDocument
Set ComElementValueById of oDocument "username" to "Mr.Smith"
Set ComElementValueById of oDocument "password" to "supersecret"
End_Procedure
End_Object
Example in VB6:
Document.ElementValueById("username") = "Mr. Smith"
Document.ElementValueById("password") = "supersecret"
Document.ElementValueById("your-none-existing-input") = "smith@example.com"
There's also a synchronous alternative SetElementValueByIdSync that wraps the the property and event into one call.
See also: RequestElementValueById
Example:
AntView - The MS Edge WebView2 ActiveX control Date last changed: 09/30/2024