I am trying to get an html table to work properly in android with an onclick event for certain rows and cells.
It's supposed to get user input from 2 rounds, then add them up and then keep adding up after each round till the 7th round. This is my code so far and everything runs fine on the PC but when I go to do it through my tablet ver 4.2.2 I get no results from the inputs.
Sample Code:
Javascript / HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
function calcP1()
{
var p1ro1 = document.getElementById("p1r1").value;
var p1ro2 = document.getElementById("p1r2").value;
var pl1 = document.getElementById("p1").value;
var sum1 = (parseInt(p1ro1) + parseInt(p1ro2));
document.getElementById("sp1r2").value = sum1;
}
/*]]>*/
</script>
</head>
<body>
<table>
<tr>
<td>Player Names:</td>
<td><input type="text" id="p1"/></td>
</tr>
<tr>
<td>Round 1: 2 Books</td>
<td><input type="text" id="p1r1"/></td>
</tr>
<tr>
<td>Round 2: 1 Book 1 Run</td>
<td><input type="text" id="p1r2"onclick="calcP1();"/></td>
</tr>
<tr>
<td>Total Round 1 & 2 </td>
<td bgcolor="#00FF00"><input type="text" id="sp1r2" readonly /></td>
</tr>
</table>
</body>
</html>
TableActivity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.table);
wv = (WebView)findViewById(R.id.tables);
wv.loadUrl("file:///android_asset/ScoreCard.html");
}
Would I have to use addJavascriptInterface into my TableActivity so how? Thank you.