Skip to content Skip to sidebar Skip to footer

How To Show Qrc Scan Results On Input Text

Am trying out barcode scanning/reader in phonegap. I have managed to read the QR codes but now am stack on how I can show results on the input text. Js for Scanning

Solution 1:

<script type="text/javascript">
  function scan(){   
       cordova.plugins.barcodeScanner.scan(
              function (result) {
               var qrc = result.text;         
               document.getElementById("qrc").value=qrc.toString();

             }, 
              function (error) {
                  alert("Scanning failed: " + error);
              });
    }
</script>

Solution 2:

We can assign a value to text fields, like this $('#qrc').val(qrc); if you are not using jquery then document.getElementById("qcr").value = qcr;

<script type="text/javascript">
            function scan()
        {
                   cordova.plugins.barcodeScanner.scan(
                  function (result) {
                  var qrc = result.text; 
                      alert("We got a barcode\n" +
                            "Result: " + result.text + "\n" +
                            "Format: " + result.format + "\n" +
                            "Cancelled: " + result.cancelled + "\n" +
                            "QRC: " + qrc); 
                          $('#qrc').val(qrc); // Added this line

                  }, 
                  function (error) {
                      alert("Scanning failed: " + error);
                  });
        }
        </script>

Post a Comment for "How To Show Qrc Scan Results On Input Text"