Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to fill text field programatically in a web page opened inside a WebView. How To?

Tags:

java

android

I have created a WebView and opened up a web page in it that contains a form. I need to fill that form programmatically (need to get some data form sqlite database and fill it).

how i can do that ? can anyone please help me out.

EDIT : the web page is a sign-up form and i do not own that web page.. i cannot add java script into that page.

like image 371
g.revolution Avatar asked Feb 10 '12 03:02

g.revolution


1 Answers

I would use javascript in this situation.

Here is how. Make your webview javascript-enabled.

Java code in your webview activity

webview.loadUrl("javascript: fillUpForm(inputId,inputValue)");

javascript in your html file

function fillUpForm(id,value)
{
  document.findElementById(id).value=value;
}

Frankly, I am no expert in javascript. But this should give you starting point.


Well, in your case,

I would try this

view.loadUrl("javascript:(function(){document.getElementById('trop').value='some value';})()");
like image 182
PH7 Avatar answered Oct 06 '22 00:10

PH7