### Get & Set Field Value

Example of getting & setting the value of a field (requires the JavaObject library).
HTML Code Index.html
<html>
<body>
<form action="action.php">
<input type="text" name="name" value="Name" /></br>
<input type="text" name="email" value="EMail@Test.de" /></br>
<input type="submit" value="Submit" />
</form>
</body>
</html>
B4J Code
'Set the value of a field in a webview
'Example:
'Private wvMain As WebView
'Dim joWV As JavaObject = wvMain
'WebView_SetField(wvMain, "name", "mynewname")
`Sub WebView_SetField(wv As WebView, field As String, value As String)
Dim joWV As JavaObject = wv
Try
joWV.RunMethodJO("getEngine", Null).RunMethod("executeScript", _
Array As String("document.getElementsByName('" & field & "')[0].value = '" & value & "'"))
Catch
Log(LastException)
End Try
End Sub`
'Get the value of a field in a webview
'Example:
'Private wvMain As WebView
'Dim joWV As JavaObject = wvMain
'Log(WebView_GetField(wvMain, "name"))
`Sub WebView_GetField(wv As WebView, field As String) As String
Dim joWV As JavaObject = wv
Try
Return joWV.RunMethodJO("getEngine", Null).RunMethod("executeScript", _
Array As String("document.getElementsByName('" & field & "')[0].value"))
Catch
Log(LastException)
Return ""
End Try
End Sub`

Changed: , Category: WebView, File: T6C284M2128.htm, ID: 2128