Android Question Submitting web form (click button) with WebViewExtras1

RB Smissaert

Well-Known Member
Licensed User
Longtime User
This is the webpage I am dealing with:
https://qrisk.org/three/index.php

Managed now to populate all the controls properly, but having problems submitting the form, so pressing the Calculate risk button. Tried many variations, but it seems this should do it:

B4X:
 Javascript = "document.forms.calculator.submit();"
 WebViewExtras1.executeJavascript(WebView1, Javascript)

But it doesn't, just sets all the controls to blank.

This is the html related to that button:

B4X:
</fieldset>
</fieldset>
</fieldset>
<input type='submit' value='Calculate risk' name="calculate">
</form>
</TD>
<TD>
<h4>The QRISK<sup>&reg;</sup>3 algorithm</h4>

Any suggestions how this should be done?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Why use WebView at all? Why not send the request with OkHttpUtils2?

Because I have a WebView running in the app at that time showing that web page and
because I have never used OkHttpUtils2 and because it looks it should work with WebviewExtras.
Thanks for that suggestion though and will have a look at OkHttpUtils2.

RBS
 
Upvote 0

rraswisak

Active Member
Licensed User
Change the javascript with this:

B4X:
Javascript = $"document.getElementsByName("calculate")[0].click();"$
 
Upvote 0
Top