I am having 2 related problem with javascript in webview.
The first is that when I check a checkbox in the html page it will sometimes but not always display the checkbox as checked. So, to help the user I also use a label and also set the onclick event to document.getElementById('checkbox')=checked and still it only sometimes works:
<label><input type="checkbox" class="big" id="checkbox' + (i-1) +'" name="activities" value="' + (i-1) + '"><a onclick="document.getElementById(checkbox' + (i-1) +')=checked">' + questionsTexts[i-1] + '</a></label>
The second is that when I try to open a new page i use
function clickNextPage(url) {
//write to cookies here
//end write to cookies
var HtmlStr = "ict4d_198_19815d.html?num_questions="+num_questions+"&";
for(i=1; i<=num_questions; i++) {
if (document.getElementById("checkbox" + (i-1)).checked)HtmlStr+="arrId"+(i-1)+"="+(i-1)+"&";
}
window.location=""+HtmlStr;
return false;
}
Originally I passed it to the activity and used loadUrl(url) but this did not work as i could not get the webview to loadUrl. I tried this.loadUrl webview.loadUrl super.loadUrl but nothing would work so I went back to doing it in the javascript code with window.location. Again, it only works sometimes. Tried window.location.href also to no avail.
All these issues don't exist in the HTC Desire but do in the Samsung Galaxy S.
Does anyone have a workaround that is foolproof?
Thanks.