Been searching a way to detect real time change on the input but not changed by user which is changed by also a code
Example: QR Scanned(not my code lib. only) > text output will go to certain text input > when text changed it throws an alert and nothing will happen if there's no scanned or the value is recent scanned.
My current progress to that code is pasted below, it is not working unless it was change by user qr text output is working but alert not working since it will no get triggered by the "change".
$("#UUID").on("change", function(e) {
var UUID = document.getElementById("UUID").value;
if ("SCANNING" != UUID) {
alert(UUID);
}
});
the idle value of text input is "SCANNING" thats why i left the if else statement != "SCANNING" so it will throw alerts when not getting scan by other output/value. Hoping to get help in not throwing alerts to when scanning the same value so it won't spam alerts.
Here's a video demo of the scanner via Imgur
I finally solved it, I was looking for the functionality of throwing the text value of qr text output and created a global variable and added a call function line in the end of the qr text output then send the variable of it to the internal js.
So here's the code line i modified from the QR scanner:
var ScannedUUID; //created global variable
function read(a)
{
var html="<br>";
if(a.indexOf("http://") === 0 || a.indexOf("https://") === 0)
html+="<a target='_blank' href='"+a+"'>"+a+"</a><br>";
html+="<b>"+htmlEntities(a)+"</b><br><br>";
document.getElementById("result").innerHTML=html;
document.getElementById("UUID").value= a;
ScannedUUID; = a; //set the qr text out value to global
scannedTransfer(); //call the function from the index.html
}
Here's the index.html:
<script type="text/javascript" src="./webqr.js"></script>
<script>
function scannedTransfer(){
//so created a local variable for new variable of out global
var UUID = ScannedUUID;
//added some output for testing
console.log("Working, Scanned: " + UUID)
alert(UUID);
}
</script>