Android Question Problem setting values 2 webpage controls

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Installed the WebViewExtras library (1.42) and trying to set the values of the controls on this webpage:
https://qrisk.org/three

All working perfectly fine, except for 2 controls, called sbps5 and weight.
There is no error but they just remain blank.
I tried with sleep(0) and sleep =(10) etc. and also tried to run the code repeatedly in a loop, but always
these 2 controls remain blank. I have checked the provided values with a log and they are fine. I can enter
the values manually on the webpage fine.

B4X:
 Javascript = "document.forms.calculator.sbp.value='" & tQR3.iSysBP & "';"
 WebViewExtras1.executeJavascript(WebView1, Javascript) '<<<< FINE
  Javascript = "document.forms.calculator.sbps5='" & Round2(tQR3.dSD_BP, 2) & "';"
 WebViewExtras1.executeJavascript(WebView1, Javascript) '<<<< REMAINS BLANK
 Javascript = "document.forms.calculator.height.value='" & 160 & "';"
 WebViewExtras1.executeJavascript(WebView1, Javascript) '<<<< FINE
 iWeight = CInt(Round2(tQR3.dBMI * 2.56, 0))
  Javascript = "document.forms.calculator.weight='" & iWeight & "';" '<<<< REMAINS BLANK
 WebViewExtras1.executeJavascript(WebView1, Javascript)
 WebView1.Invalidate

I also tried with all the javascript (altogether 23) Javascript lines in one string and one WebViewExtras1.executeJavascript(WebView1, JavaScript)
but again same result.

The control names are fine, copied from the web source.

Any idea what the problem could be here?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Installed the WebViewExtras library (1.42) and trying to set the values of the controls on this webpage:
https://qrisk.org/three

All working perfectly fine, except for 2 controls, called sbps5 and weight.
There is no error but they just remain blank.
I tried with sleep(0) and sleep =(10) etc. and also tried to run the code repeatedly in a loop, but always
these 2 controls remain blank. I have checked the provided values with a log and they are fine. I can enter
the values manually on the webpage fine.

B4X:
 Javascript = "document.forms.calculator.sbp.value='" & tQR3.iSysBP & "';"
 WebViewExtras1.executeJavascript(WebView1, Javascript) '<<<< FINE
  Javascript = "document.forms.calculator.sbps5='" & Round2(tQR3.dSD_BP, 2) & "';"
 WebViewExtras1.executeJavascript(WebView1, Javascript) '<<<< REMAINS BLANK
 Javascript = "document.forms.calculator.height.value='" & 160 & "';"
 WebViewExtras1.executeJavascript(WebView1, Javascript) '<<<< FINE
 iWeight = CInt(Round2(tQR3.dBMI * 2.56, 0))
  Javascript = "document.forms.calculator.weight='" & iWeight & "';" '<<<< REMAINS BLANK
 WebViewExtras1.executeJavascript(WebView1, Javascript)
 WebView1.Invalidate

I also tried with all the javascript (altogether 23) Javascript lines in one string and one WebViewExtras1.executeJavascript(WebView1, JavaScript)
but again same result.

The control names are fine, copied from the web source.

Any idea what the problem could be here?
RBS

Seem to have fixed this:

B4X:
 Javascript = "document.getElementById('weight').value='" & iWeight & "';"
 WebViewExtras1.executeJavascript(WebView1, Javascript)

It looks if the source shows an ID then it is better to use that.

RBS
 
Upvote 0
Top