Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda