mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / GetInputValue Method

The CSS3 Selector of an INPUT Element.

If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

In This Topic
    GetInputValue Method
    In This Topic
    Description

    Get INPUT element value directly.

    Syntax
    Visual Basic
    Public Function GetInputValue( _
       ByVal Selector As String _
    ) As String
    Parameters
    Selector

    The CSS3 Selector of an INPUT Element.

    If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

    Return Type

    The value of the INPUT Element.

    Remarks

    This method is provided for direct access to INPUT element's value. Please note the name attribute is required for form submission but it is not a valid identifier of the HTML elements. To read or write values to INPUT elements of a FORM in modern HTML5 you need to use the id attribute or create a relative CSS3 selector. The relative CSS3 selector of the INPUT element in the following example is body > form > input but it depends on your HTML layout. You cannot access the form elements it using their name attribute. In the following example note the different values of name and id attributes and the CSS3 selector used to read and write to the elements.

    Example
    Option Explicit
    
    Private Sub Form_Load()
    
        ' Enable high dpi support in current process.
        ' This will work with compiled executable but not VB6 IDE
        WebKitX1.EnableHighDPISupport
        
    End Sub
    
    Private Sub Form_Resize()
        On Error Resume Next
        WebKitX1.Move 0, 0, ScaleWidth, ScaleHeight - Picture1.Height
        Err.Clear
    End Sub
    
    Private Sub WebKitX1_OnCreate(ByVal Settings As WebKitXCEF3Lib.ISettings, CommandLineSwitches As String)
        
        Settings.plugins = True
        Settings.cache_path = App.Path + "\MyCache"
        Settings.application_cache = App.Path + "\MyAppCache"
        Settings.persist_session_cookies = 1
        Settings.persist_user_preferences = 1
            
        ' Enable high dpi support for CEF and current process
        Settings.enable_high_dpi_support = True
        
    End Sub
    
    Private Sub WebKitX1_OnBrowserReady()
        
        WebKitX1.Open "file:///" + App.Path + "/form.html"
        
    End Sub
    
    Private Sub cmd_GetValue_Click()
    
        ' To access <INPUT> elements inside a <FORM> you need
        ' to use a valid CSS3 selector. This means you need
        ' to either add "id" attreibute to your elements
        ' or use a relative CSS3 tag-selector such as "body form input"
        ' You cannot use the "name" attribute to access elements.
    
        MsgBox WebKitX1.GetInputValue("#frm1 #inp1")
    
    End Sub
    
    Private Sub cmd_SetValue_Click()
    
        ' To access <INPUT> elements inside a <FORM> you need
        ' to use a valid CSS3 selector. This means you need
        ' to either add "id" attreibute to your elements
        ' or use a relative CSS3 tag-selector such as "body form input"
        ' You cannot use the "name" attribute to access elements.
        
        WebKitX1.SetInputValue "#frm1 #inp1", "How are you?"
     
    End Sub
    <html>
    <body>
    
    <form id="frm1" name="form1">
    
    	<input id="inp1" name="input1" value="Hello!"/>
    
    </form>
    
    </body>
    </html>
    See Also