[英]How to write onComplete function?
How to change this line of code? 如何更改这一行代码?
I tried to do barcode scanning just from html to get exact data from same as what i got in notepad. 我试图从html进行条形码扫描,以从记事本中获取相同的确切数据。
$(document).scannerDetection({
timeBeforeScanTest: 200, // wait for the next character for upto 200ms
avgTimeByChar: 40, // it's not a barcode if a character takes longer than 100ms
preventDefault: true,
endChar: [7],
$("#userInput").onComplete(function(){ //i got error here.. why?
validScan = true;
alert("Job Start");
var text = $(this).text();
var barcode = text.substring(1,4);
$('input[type="text"]').val(barcode);
)};
// } // main callback function ,
//,
//onError: function(string) {
//$('#userInput').val ($('#userInput').val() + string);
//}
});
</script>
</head>
<body>
<p><strong> Scan BarCode : </strong></p>
<input id="userInput" type="text" autofocus readonly/><br/><br/><br/>
<p><strong> BarCode : </strong></p>
<p> <input type="text" readonly/></p><br/><br/><br/>
<p><strong> Zone : </strong></p>
<p> <input id="zone" type="text" readonly/></p><br/><br/><br/>
</body>
</html>`
i got error in line 16... the way i wrote onComplete function is false. 我在第16行出现错误...我编写onComplete函数的方式为false。
As @Jay suggested your function is not closed properly and try to read the below source on how to use oncomplete 由于@Jay建议您的函数未正确关闭,请尝试阅读以下有关如何使用oncomplete的资源
https://a.kabachnik.info/jquery-scannerdetection-tutorial.html https://a.kabachnik.info/jquery-scannerdetection-tutorial.html
$("#userInput").onComplete(function(){ //i got error here.. why?
validScan = true;
alert("Job Start");
var text = $(this).text();
var barcode = text.substring(1,4);
$('input[type="text"]').val(barcode);
});
<script type="text/javascript" src="your_path/jquery.scannerdetection.js"></script>
<script type="text/javascript">
$(document).scannerDetection({
timeBeforeScanTest: 200, // wait for the next character for upto 200ms
startChar: [120], // Prefix character for the cabled scanner (OPL6845R)
endChar: [13], // be sure the scan is complete if key 13 (enter) is detected
avgTimeByChar: 40, // it's not a barcode if a character takes longer than 40ms
onComplete: function(barcode, qty){ ... } // main callback function
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.