Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 输入框内装有条形码扫描仪_Javascript_Php_Jquery_Barcode Scanner - Fatal编程技术网

Javascript 输入框内装有条形码扫描仪

Javascript 输入框内装有条形码扫描仪,javascript,php,jquery,barcode-scanner,Javascript,Php,Jquery,Barcode Scanner,我有输入框,可以从条形码扫描仪输入填写 <input type="text" autofocus class="form-control m-input" id="productSearch" aria-describedby="emailHelp" placeholder="Product name"> 但问题是,每当输入框中充满输入时,它都应该变为空,并向表中添加相关值。 我使用了下面的函数来实现这一点。相关值会自动添加到表中,但问题是它也会显示自动建议。如何停止

我有输入框,可以从条形码扫描仪输入填写

 <input type="text"  autofocus class="form-control m-input" id="productSearch" aria-describedby="emailHelp" placeholder="Product name">   

但问题是,每当输入框中充满输入时,它都应该变为空,并向表中添加相关值。 我使用了下面的函数来实现这一点。相关值会自动添加到表中,但问题是它也会显示自动建议。如何停止显示autosuggestion并使值为空

$("#productSearch").keypress(function(event) {
  if (event.which == '10' || event.which == '13') {
    // alert(this.value)
    $.ajax({
      type: "get",
      url: "{!! asset('searchByProductName') !!}",
      dataType: 'json',
      data: {
        name: this.value
      },
      success: function(response) {
        // console.log(response)
        if ($('#' + response.id).length !== 0)
          return;

        var markup = "<tr id=" + response.id + "><input type='hidden' name='product_id[]'  value=" + response.id + "><td><i class='flaticon-delete-1 delete-row' onclick='deleteRow(this)'></i></td><td>" + response.product_name + "</td><td>" + response.product_unit_price + "</td><td><input type='text' name='quantity[]' class='quantity' value='1'></td><td class='total'>" + response.product_unit_price + "</td><td>" + response.notes + "</td></tr>";

        $("table tbody").append(markup);
        calculateSum();

        $('.quantity').on('keyup', function() {
          var currentRow = $(this).closest("tr");
          var col3 = currentRow.find("td:eq(2)").text();
          var data = col3 * $(this).val();
          currentRow.find("td:eq(4)").text(data.toFixed(2))
          calculateSum();
        });

        $(this).val("");
        return false;
      }
    });
    event.preventDefault();
  }
});
$(“#产品搜索”)。按键(功能(事件){
if(event.which==“10”| event.which==“13”){
//警报(此.value)
$.ajax({
键入:“获取”,
url:“{!!资产('searchByProductName')!!}”,
数据类型:“json”,
数据:{
名称:this.value
},
成功:功能(响应){
//console.log(响应)
if($('#'+response.id).length!==0)
返回;
var markup=”“+response.product\u name+“”+response.product\u单价+“”+response.product\u单价+“”+response.notes+“”;
$(“表tbody”)。追加(标记);
计算um();
$('.quantity')。在('keyup',function()上{
var currentRow=$(此);
var col3=currentRow.find(“td:eq(2)”).text();
var data=col3*$(this.val();
currentRow.find(“td:eq(4)”).text(data.toFixed(2))
计算um();
});
$(此).val(“”);
返回false;
}
});
event.preventDefault();
}
});

这里要提一下。如果条形码扫描器找不到值,我也用上面的输入框实现了自动提示。

条形码扫描器就像键盘一样工作。这是一个文本输入设备。将函数写入文本框的文本更改事件。检查字符串的长度,调用函数将字符串添加到数据库并清除文本字段。 希望这有帮助

关闭自动完成

<input type="text"  autofocus class="form-control m-input" id="productSearch" aria-describedby="emailHelp" placeholder="Product name" autocomplete="off"> 

我无法停止自动完成..就好像条形码扫描仪无法读取输入一样,我需要在需要自动完成建议的地方手动键入