Encountering an issue while attempting to populate fields in my android web view. Consistently receiving this error message
01-28 05:06:22.980: E/Web Console(2827): Uncaught TypeError: Cannot set property 'value' of null at null:1
Despite searching, I have not found a solution yet. How can I troubleshoot and fix this problem? Here is the code snippet:
public void onStart() {
super.onStart();
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
String url = "file:///android_asset/index.html";
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient(){
public void onPageFinished(WebView view, String url) {
webView.loadUrl("javascript: {"
+ "document.getElementById('AddSerialNum').value = '"
+ ABC
+ "';"
+ "document.getElementById('ctl00_PageContent_lblName').value = '"
+ ABC + "';};");
}
});
}
This file contains the index.html content:
<!DOCTYPE html>
<html>
<body>
<div style="BORDER-BOTTOM: #dfdfdf 3px solid; PADDING-BOTTOM: 1px; MARGIN-BOTTOM: 10px; HEIGHT: 25px;">
......
<div style="padding: 10px;">
<table width="100%">
<tbody><tr>
<td>
<div style="float: left;">
<div>
<form>Serial Number: <input type="text" name="AddSerialNum"></form><br><br>
<span id="ctl00_PageContent_lblName" style="font-weight:bold;"></span>
</div>......
Looking for options to fill the fields and retrieve data later using Java. Any suggestions would be appreciated.
Thank you in advance.