1
I’m trying to get the QR code to be scanned it prints its value in the input, but I’m not getting it, I used some functions I know but the qr code is not printed in the input in any way, I’m new at this.
<!DOCTYPE html>
<html>
  <head>
    <title>Instascan</title>
    <script type="text/javascript" src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js" ></script> 
  </head>
  <body>
  
    <video id="preview"></video>
    
    <script>
        let scanner = new Instascan.Scanner(
            {
                video: document.getElementById('preview')
            }
        );
        scanner.addListener('scan', function(content) {
            alert('Escaneou o conteudo: ' + content);
        });
        Instascan.Camera.getCameras().then(cameras => 
        {
            if(cameras.length > 0){
                scanner.start(cameras[0]);
            } else {
                console.error("Não existe câmera no dispositivo!");
            }
        });
        
        var opa = "teste"
    </script>
    
    <input type="text" id="myText" value=""> </input>   
    <p><button onclick="myFunction()" id="meuElemento">QR CODE</button></p>
    <script>
    
    var botao = document.getElementById("meuElemento");
    botao.onclick = function myFunction() {
      document.getElementById("myText").value = content; 
    }
    // alerta de presença cadastrada
    function myFunction2() {
      alert("Presença Cadastrada!");
    }
    </script>
    
 </body>
</html>
In the case, you were referring to getting the input ID?
– André Cabral
That. If you are not using id, it would be good to put to discriminate the element.
– Rodrigo Carvalho de Brito
Do some tests with recognition but I did not succeed, apparently I do not know what happened, I am very new in this field. But I will use a "gambiarra" at the moment so I can be including the value in the database.
– André Cabral
After swapping the #id_send_field ID for #myText, it did not work, the console presented the following error, "Referenceerror: $ is not defined"
– André Cabral
The id has to be the "input", maybe that’s it. I suffered also at first.
– Rodrigo Carvalho de Brito
Thanks friend, you managed to open my mind to a question that was simple. I left the code below if you want to take a look
– André Cabral