Below is the entirety of the javascript code in question This code works on desktop, however on an android device, it fails to colour the table element green Presumably the listeners are what's broken but I do not have extensive debugging on the particular android device, the input device is a scanner, something which I also have for my desktop.
<script>
// document.getElementById("title").setAttribute("innerHTML", "")
let text = ""
document.addEventListener('keydown', (event) => {
if (event.key != 'Enter') {
var name = event.key;
var code = event.code;
text += event.key
}
}, false);
document.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
console.log(text)
//myFunction(1);
TableIt(text);
text = ""
}
})
function myFunction(string) {
document.getElementById(string).setAttribute("bgcolor","#dee")
}
function TableIt(text) {
var table = document.getElementById("VareTable");
for (var i = 0, row; row = table.rows[i]; i++) {
//rows would be accessed using the "row" variable assigned in the for loop
for (var j = 0, col; col = row.cells[j]; j++) {
if (col.innerHTML === text) {
myFunction(i-1);
}
//columns would be accessed using the "col" variable assigned in the for loop
}
}
}
</script>
Tried to do eventlistener('input', (event) => { . . . .
but to no success
Edit;
here is the full html above the JS
@page
@model WebStore.Pages.VareModel
@{
}
<br />
<h2 id="title">@(Model.Loc.Location)</h2>
<table class="table" id="VareTable">
<thead>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Description</th>
<th>EanNum</th>
</tr>
</thead>
<tbody>
@foreach (var Info in Model.listItems)
{
<tr id="@Info.ItemID">
<td>@Info.Item</td>
<td>@Info.Qty</td>
<td>@Info.Description</td>
<td id="@Info.ItemID ean">@Info.EAN</td>
</tr>
}
</tbody>
</table>