I want to let users enter the vehicle number and then read the data and show the vehicle details to the user. I don't want to do it in a webview. I am able to fill the data using this code:
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://parivahan.gov.in/rcdlstatus/vahan/rcstatus.xhtml");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
String reg1="KA51X";
String reg2="2442";
if(isFirstLoad) {
webView.loadUrl("javascript: {" +
"document.getElementById('convVeh_Form:tf_reg_no1').value = '" + reg1 + "';" +
"document.getElementById('convVeh_Form:tf_reg_no2').value = '" + reg2 + "';" +
"var frms = document.getElementsByName('convVeh_Form');" +
"frms[0].submit(); };");
isFirstLoad = false;
}
}
});
Here is the website which shows the data for this app.
https://parivahan.gov.in/rcdlstatus/vahan/rcstatus.xhtml
Now I am trying to click the submit button using this line
"frms[0].submit(); };");
and this,
"javascript:(function(){document.getElementById('convVeh_Form:j_idt21').click();})()"
but they are not working. How to click the button whose Id is
convVeh_Form:j_idt21
Also, once able to click the button, the response will come from the website. How to read that response text and put it in textview of app.?