1

I am new to instascan. When I checked the scan by QRCode, everything works fine. But if I try to switch to manual, it does not work. It seems the input type is disabled, but the reset button work fine. My code is:

<javascript>
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
      scanner.addListener('scan', function (content) {
        decode(content);
        //alert(content);
      });
      Instascan.Camera.getCameras().then(function (cameras) {
        if (cameras.length > 0) {
          scanner.start(cameras[1]);
        } else {
          alert("no camera found");
        }
      }).catch(function (e) {
        console.error(e);
      });
    $("#choose").on("change", function(){

        if(document.getElementById('qrcode').checked) {
          document.getElementById("manual").style.display="none";
          document.getElementById("qrcoded").style.display="block";
        }else {
          document.getElementById("qrcoded").style.display="none";
          document.getElementById("manualed").style.display="block";
        }
    });
</javascript>
<html>
<div id="choose">
<input type="radio" style="display:none" name="choose" id="qrcode" value="qrcode"><label for="qrcode">qrcode</label>
<input type="radio" style="display:none" name="choose" id="manual" value="manual"><label for="manual">manual</label>
</div>
<div class="col-md-12" id="qrcoded" style="display:none;">
    <div class="preview-container">
        <video width="50%" id="preview"></video>
    </div>
    <button class="btn btn-default btn-sm" onclick="reset()">Reset</button></h2>
</div>
<div class="col-md-12" id="manualed" style="display:none">anything</div>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ruping Wen
  • 11
  • 1

0 Answers0