I am not a programmer and what I have "written" is mostly copied from others, However I'. in a dire need of a solution. What I have in mind is comparing two arrays, one of which is filled with strings from and the other is filled by a bluetooth QR reader, so that I can compare the two arrays and mark duplicate values as "found" (it's an inventory system). However when I try to read a QR code into an input it automatically redirects me to a new browser page. (the code i scanned is no URL, its just an inventory number in a ###/### format) My input works perfectly when I use keyboard.. and since key logger claims that the only button the reader has is "13" I assumed it would behave just like a regular "13" Enter.. when I abused a slower computer at work I found out that it actually does as intended, writes the number into the input, "submits" it by pressing enter.. and then it redirects away.. any ideas to stop it from doing so? Thanks, Michal
<input type="file" id="file-selector" accept=".csv">
<button id="btn-upload-csv">Read CSV</button>
<br>
<input id="scanID">
<button id="buttonS" onClick="spustit()">Spustit</button>
<button id="buttonR" onClick="reset()">Reset</button>
<p id="pole"></p>
<p id="pole2"></p>
<table id="tbl-data"></table>
<script>
let btn_upload = document.getElementById("btn-upload-csv").addEventListener("click", ()=>{
Papa.parse(document.getElementById("file-selector").files[0],{download: true,
header: false,
complete: function(results){console.log(results);
}
});
});
var cele=[];
function spustit() //Zeptat se jak zakázat prázdné scany array.filter?
{
nove=[(document.getElementById("scanID").value)];
cele.push(nove);
document.getElementById("pole").innerHTML=cele;
document.getElementById("scanID").value="";
}
function reset()
{
cele=[];
document.getElementById("pole").innerHTML=cele;
}
var input = document.getElementById("scanID");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
spustit();
}
});
const fileSelector = document.getElementById("file-selector");
fileSelector.addEventListener('change', (event) => {
const fileList = event.target.files;
console.log(fileList);
});
</script>