'problem with showing values of my array with document.write (using HTML 5 QR Code Scanner)
I am trying to work with HTML 5 QR Code scanner foran attendance system. Well I got that far, that I can scan QR Codes and push them into an array. I can see the values of the array in the console. Now I want that this array is shown below the QR Code Reader in my browser view. I then want a form to submit my javascript array values to a PHP Code to use it with mysql (Don`t know how to do that right know... :) )
My first problem: my html page is not showing anything.. it is supposed to show the values of my Code array:
<script>
var codeslz = [];
function onScanSuccess(decodedText, decodedResult) {
// handle the scanned code as you like, for example:
//console.log(`Code matched = ${decodedText}`, decodedResult);
if(codeslz.indexOf(decodedText) !== -1){
} else{
codeslz.push (decodedText);
}
console.log (codeslz);
return codeslz;
}
function onScanFailure(error) {
// handle scan failure, usually better to ignore and keep scanning.
// for example:
//console.warn(`Code scan error = ${error}`);
}
let html5QrcodeScanner = new Html5QrcodeScanner(
"reader",
{ fps: 10, qrbox: {width: 350, height: 350} },
/* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess, onScanFailure);
for(var i = 0; i < codeslz.length; i++){
document.write(codeslz[i] + "<br>");
}
</script>
Later I want to automatically let the shwoing of my array be reloaded, so the user can always see the actual values of the complete array codeslz.
I think there must be sth wrong with my array codeslz. When I fill the array like this, it works without any problems:
<html>
<head>
</head>
<body>
<script>
var codeslz = ["This", "is","a", "Test"];
for(var i = 0; i < codeslz.length; i++){
document.write(codeslz[i] + "<br>");
}
</script>
</body>
</html>
I hope someone can help me. Thanks!!!! Kind regards Dan
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
