PHP 和条形码扫描仪
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2900010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP and Barcode Scanners
提问by Mostafa Elkady
If i have a website running php and apache, what do i need to be able to attach a scanner to it? How do i get the scanner to fill in a value on one of the webforms on my page?
如果我有一个运行 php 和 apache 的网站,我需要什么才能将扫描仪连接到它?我如何让扫描仪在我页面上的其中一个网络表单上填写一个值?
回答by John Conde
I just did this for an application. It's actually simple. The scanner is just another input method and is, in fact, similar to a keyboard. When you scan the barcode the data is decoded by the scanner and sent to whatever application is waiting to receive it. In the case of a web-based application it would be a form, most likely with a textarea with focus. The data would then populate the textarea just as if someone had typed the barcode's data into it. The form is then submitted and processed normally.
我只是为一个应用程序做了这个。其实很简单。扫描仪只是另一种输入法,实际上类似于键盘。当您扫描条形码时,数据由扫描仪解码并发送到任何等待接收它的应用程序。在基于 Web 的应用程序的情况下,它将是一个表单,最有可能是带有焦点的文本区域。然后数据将填充文本区域,就像有人将条码的数据输入其中一样。然后表单被正常提交和处理。
Just make sure the textarea has focus or else the data will go either nowhere or to wherever focus is (which may be another form field or the address bar).
只需确保 textarea 具有焦点,否则数据将无处可去或焦点所在的任何地方(可能是另一个表单字段或地址栏)。
I have yet to figure how how to get the form to auto-submit upon the entry of the barcode data as the scanner does not send event information (i.e. submit) and special characters such as tab (\t) do not seem to work. (If anyone knows how to accomplish this I am very interested in knowing how it can be done).
我还没有弄清楚如何让表单在输入条码数据时自动提交,因为扫描仪不发送事件信息(即提交)并且特殊字符(如制表符 (\t) 似乎不起作用)。(如果有人知道如何做到这一点,我很想知道如何做到这一点)。
回答by Mostafa Elkady
For actually creating barcodes in PHP, you might want to have a look at:
要在 PHP 中实际创建条码,您可能需要查看:
http://www.mribti.com/barcode/
http://www.mribti.com/barcode/
回答by WhirlWind
Usually, these scanners are equivalent to a keyboard input, so you just select the appropriate input point on the web page, scan, and then submit the form.
通常,这些扫描仪相当于键盘输入,因此您只需在网页上选择合适的输入点,扫描,然后提交表单即可。
回答by JYelton
WASPmakes a line of barcode scanners that simply plug into USB or PS/2 inputs and basically convert the barcode scanned into the characters, just like a user typed them using a keyboard. They have an FAQ and help videos that may be of assistance, too.
WASP生产了一系列条码扫描器,只需插入 USB 或 PS/2 输入,基本上将扫描的条码转换为字符,就像用户使用键盘输入它们一样。他们有一个常见问题解答和帮助视频,也可能有帮助。
When designing your web app, depending on how users interact with it, you can use Javascript to move focus from one field to another so that a user can scan barcodes sequentially without having to click on the field where the characters go. (Similar to how some forms move focus as you type data with a known length, such as a zip code or phone number.)
在设计您的 Web 应用程序时,根据用户与它的交互方式,您可以使用 Javascript 将焦点从一个字段移动到另一个字段,以便用户可以按顺序扫描条形码,而无需单击字符所在的字段。(类似于某些表单在您键入具有已知长度的数据(例如邮政编码或电话号码)时移动焦点的方式。)
回答by kishan Radadiya
You can try this:
你可以试试这个:
I think this is the best way to integrate barcode in web application using php.
我认为这是使用 php 将条形码集成到 Web 应用程序中的最佳方式。
integrating barcode scanner into php application?
I hope this link is usefull to all.
我希望这个链接对所有人有用。
回答by Mpwanyi Samuel
Using an autofucus input is the better way. You just have to make sure that you create a for and add autofocus to the input box. So each time a user scans any item, the form is automatically submitted. So just give the form an id and handle the data easily with jquery
使用自聚焦输入是更好的方法。您只需要确保为输入框创建一个 for 并将自动对焦添加到输入框。因此,每次用户扫描任何项目时,都会自动提交表单。所以只需给表单一个 id 并使用 jquery 轻松处理数据

