Android Question How do I input string to a webview textbox?

Mohamed Akbarally

Member
Licensed User
Longtime User
I have searched but not found anything related to inputting a string, this is the only code ive been trying but it doesn't seem to work. i am just trying to change the password value. Is there something wrong with my java script. please help i have never done something like this before.

B4X:
Sub WebView1_PageFinished (Url As String)
  If Url="https://osc.managebac.com/login" Then
      Dim Javascript As String
      Dim MyWebViewExtras As WebViewExtras  '  you could make this a global variable if you use it elsewhere in your code
      Javascript="document.body.form.input.password.value='MyUserNameHere'"
      MyWebViewExtras.executeJavascript(WebView1, Javascript)
      Log("Form submitted")
  Else
      Log("Page_Finished "&Url)
  End If

End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Globals
   Dim wv As WebView
    Dim MyWebViewExtras As WebViewExtras
End Sub

Sub Activity_Create(FirstTime As Boolean)
   wv.Initialize("wv")
   MyWebViewExtras.Initialize(wv)
   Activity.AddView(wv, 0, 0, 100%x, 100%y)
   wv.LoadUrl("https://osc.managebac.com/login")
End Sub

Sub wv_PageFinished (Url As String)
   If Url="https://osc.managebac.com/login" Then
  Dim Javascript As String = "document.getElementById('password').value='MyUserNameHere';" & _
       "document.getElementById('login').value='MyUserNameHere';" & _
     "document.getElementById('session_submit').click()"
  MyWebViewExtras.executeJavascript(Javascript)
  Log("Form submitted")
  Else
  Log("Page_Finished "&Url)
  End If

End Sub
 
Upvote 0
Top