Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Populate Input field after QRcode or Barcode Scan

I am trying to work with https://github.com/mebjas/html5-qrcode where once I scan anything the result would be populated in input field id "output". However the output is not getting populated in output id.

var html5QrcodeScanner = new Html5QrcodeScanner(
    "qr-reader", { fps: 10, qrbox: 250 });
    
function onScanSuccess(decodedText, decodedResult) {
    // Handle on success condition with the decoded text or result.
    console.log(`Scan result: ${decodedText}`, decodedResult);
    // ...
    //html5QrcodeScanner.clear();
    // ^ this will stop the scanner (video feed) and clear the scan area.
}

//Modification Attempt starts here
let QrResult = function(onCloseCallback) {
    let scanResultParsed = document.getElementById("output");
}

QrResult.onScanSuccess = function(decodedText) {
    this.__onScanSuccess(decodedText);
}

html5QrcodeScanner.render(onScanSuccess);

function onScanSuccess(decodedText, decodedResult) {
        console.log(decodedText, decodedResult);
        if (html5QrcodeScanner.getState() 
            !== Html5QrcodeScannerState.NOT_STARTED) {
            html5QrcodeScanner.pause(/* shouldPauseVideo= */ true);
        }

        let scanType = "camera";
        if (html5QrcodeScanner.getState() 
            === Html5QrcodeScannerState.NOT_STARTED) {
            scanType = "file";
        }
        qrResultHandler.onScanSuccess(decodedText, decodedResult, scanType);
    }
    html5QrcodeScanner.render(onScanSuccess);
    
    
<script src="https://github.com/mebjas/html5-qrcode/releases/download/v2.1.6/html5-qrcode.min.js"></script>
<body>
<div id="qr-reader"></div>
<div id="qr-reader-results">
  <input id="output" name="output" type="text" readonly="readonly">
</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

How about something like

let outputContainer = document.getElementById('output');
var html5QrcodeScanner = new Html5QrcodeScanner(
    "qr-reader", { fps: 10, qrbox: 250 });
    
function onScanSuccess(decodedText, decodedResult) {
    // Handle on success condition with the decoded text or result.
    console.log(`Scan result: ${decodedText}`, decodedResult);
    outputContainer.value = decodedText;
}

html5QrcodeScanner.render(onScanSuccess);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!