Contents - Index - Top


ElementValueByName

Interface AntViewDocument

 

Type: Property

Access: Write

Parameters: String Name String Value

 

 

Set the contents for the value attribute of the html element identified by Name in the document currently loaded in the WebView2 component.

Note that the Name 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" name="username" placeholder="User Name" required />

        </div>

 

        <div class="loginPassword">

            <label for="password">Password</label>

            <input type="password" name="password" placeholder="Password" required />

        </div>

 

        <div class="loginBtn">

            <button id="submit" type="submit" name="submit">Login</button>

        </div>

    </form>

 

 

Setting this property triggers the OnSetElementValueByName event on completion as it is an asynchronous operation.

 

Note that multiple elements can match the name passed. If this is the case then only the first element that matches the name will be set.

 

Example in DataFlex:

 

   Object oFillFormButton is a Button

     Set Location to 199 40

     Set Label to "Fill Form"

     Set peAnchors to anBottomLeft

   

     Procedure OnClick

       Send ConnectBrowser to oDocument

       Set ComElementValueByName of oDocument "username" to "Mr.Smith"

       Set ComElementValueByName of oDocument "password" to "supersecret"

     End_Procedure

   End_Object

 

Example in VB6:

  Document.ElementValueByName("username") = "Mr. Smith"

  Document.ElementValueByName("password") = "supersecret"

  Document.ElementValueByName("your-none-existing-input") = "smith@example.com"

 

There's also a synchronous alternative SetElementValueByNameSync that wraps the property and event into one call.

 

See also: RequestElementValueByName

 

Example: 

Fill Form Example

 


AntView - The MS Edge WebView2 ActiveX control Date last changed: 09/25/2024