停止条形码扫描仪刷新页面
我在 HTML 表单中使用条形码扫描仪,但页面刷新时出现问题
扫描仪的输入进入此表单 (html 5):
<form>
<label for "bar_code">Item</label>
<input
name="bar_code"
id="bar_code"
onchange = "processBarCode('getitemdetails.php', this.value);"
onfocus="setStyle(this.id);"
autofocus
>
</form>
processBarCode
是一个 AJAX 函数,用于检查条形码是否在mySQL 数据库,如果将项目添加到页面下方的
我需要添加输入以使 onchange
自动工作,但仍需要禁用页面刷新。
任何想法感激不尽!
I am using a barcode scanner in an HTML form and have a problem with the page refreshing
The scanner's input goes into this form (html 5):
<form>
<label for "bar_code">Item</label>
<input
name="bar_code"
id="bar_code"
onchange = "processBarCode('getitemdetails.php', this.value);"
onfocus="setStyle(this.id);"
autofocus
>
</form>
The processBarCode
is a AJAX function that checks if the barcode is in a mySQL database and if it is adds the item to a <form>
further down the page, this works perfectly. The problem is that because the bar code scanner adds an enter to the end of the scan when the function returns it triggers a submit thus causing the page to refresh.
I need the added enter for the onchange
to work automatically but still need to disable the page refresh.
Any ideas gratefully received!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改表单元素以取消提交:
Change your form element to cancel the submit: