使用桥接扫描扫描条形码后自动提交表单

时间:2016-08-09 11:46:57

标签: javascript php

扫描到输入文字后自动提交不起作用,有人可以帮帮我吗?

这是我的代码:

<form role="form" name="form1" class="form-inline " method="post" action="result2.php">
<button type="button" value="Scan" class="btn btn-default btn-success" onclick="bridgeit.scan('scanBtn', 'onAfterCaptureScan');"><span class=" glyphicon glyphicon-qrcode"></span>  Scan barcode</button>

<script type="text/javascript">
    function onAfterCaptureScan(event)  { 
        window.document.form1.find.value = event.value; 
    }

    this.form.submit();
</script> 

1 个答案:

答案 0 :(得分:0)

请试试这个:

<form role="form" id="form1" class="form-inline " method="post" action="result2.php">
<input id="value" type="text">
</form>
<button type="button" value="Scan" class="btn btn-default btn-success"    onclick="bridgeit.scan('scanBtn', 'onAfterCaptureScan');"><span class="     glyphicon glyphicon-qrcode"></span>  Scan barcode</button>
<script type="text/javascript">
    function onAfterCaptureScan(event)  { 
        window.document.getElementById('value').value = event.value; 
        window.document.getElementById('form1').submit();
    }
</script>