I am using a javascript library to implement a QR reader so when I get the code I store it in a variable that I send to a textbox, what I need to know is how to send it to a procedure to insert the data every time it changes textbox content without using buttons.
Here is the code:
<asp:TextBox ID="txt_Person_Nm" runat="server" CssClass="form-control" ReadOnly="true" ToolTip="Person ID"></asp:TextBox>
<asp:HiddenField ID="HiddenField1" runat="server"/>
And the function:
<div class="col-md-6">
<div class="form-group row">
<video id="preview" class="col-lg-12"></video>
<script type="text/javascript">
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
scanner.addListener('scan', function (contenido) {
var test = contenido.toString();
document.getElementById('<%= HiddenField1.ClientID %>').value = test;
$("#<%= txt_Person_Nm.ClientID %>").val($('#<%= HiddenField1.ClientID %>').val());
});
Instascan.Camera.getCameras().then(function (cameras) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error('There is no camara');
}
}).catch(function (e) {
console.error(e);
});
</script>
</div>
</div>