1

Here is what I'm trying to do:

I wanted to create an android app to capture email address and phone number of the android phone.

And then, use those information to prepopulate a multi submit web form.

Say, I have a form http://unlimited-trials.com/mobijob/search.php (just think of it as text boxes for email address and phone number). If this link is opened in my phone it should be populated with my email address and phone number.

I already have a form and I can already capture phone number and email add on my app using this code below:

tMgr =(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
        mPhoneNumber = tMgr.getLine1Number();

My problem is on how to populate this data to my form. Please let me know if I'm on the right track here. Thanks

Edit:

I tried Sir Milos' idea:

HTML Code:

<input class="ui-input-text ui-body-a ui-corner-all ui-shadow-inset" data-theme="a" id="location" name="location" type="text">

Android Code:

webView.loadUrl("javascript: document.forms['location'].value ='" + somevalue+ "')");

But it didn't work. I don't know why.

1
  • Did you manage to make this work? Commented Oct 26, 2012 at 10:08

1 Answer 1

3

You can use the id of your formand try something like this:

mWebView.loadUrl("javascript: document.forms['myform_id'].value ='" + newValue + "')");

or

document.getElementById('element_id').value = '" + "stringvalue" +"'; 
Sign up to request clarification or add additional context in comments.

6 Comments

If I understood your question, you have html with insde a form, with this html, your are populating your webview in your adroid app? Then your goal is to edit some elements in your form through the app?
So, you have two textboxes in your vebview: email and phone number ? You have also their respective id. Then, with the id, you can set the vlue with the code from my answer. Of corse, this will set the values locally in your yebview.
webView.loadUrl(url); //string url, which part I can inject the javascript?
After you loaded your url, call again the code I geved to you. This will change only what you need.
thanks sir milos, it finally worked. document.getElementById('em').value = '" + "stringvalue" +"';
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.