-1

I know a barcode scanner acts like a keyboard; when the code is scanned it inputs the text in our form. But in order for it to be able to do that the cursor must be placed in the form field.

To accept input data in situations where there is no mouse (relying only on keyboard), we wrote some JavaScript to put the cursor in the concerned field.

Is there any other way to accept text from a barcode scanner when the cursor is not placed in the correct field?

user1122486
  • 11
  • 1
  • 1
  • you may get a solution by refering these http://stackoverflow.com/questions/7227535/is-it-possible-to-read-access-the-bar-code-scanner-values-using-php-mysql and http://stackoverflow.com/questions/2085066/how-to-fill-in-two-inputtext-in-an-html-form-using-a-barcode-reader – Manigandan Arjunan Dec 30 '11 at 07:19
  • You seem to be having keyboard problems already - no capitals nor punctuation? – symcbean Dec 30 '11 at 11:54

3 Answers3

1

i know barcode scanner acts like a key board

Not necessarily - but that is a common configuration. And the only way to capture data via a browser. OTOH you could write your own HTTP client to bridge the scanner to the HTTP server. You could even write a signed java applet (it'd need to be signed to get around the sandbox restrictions) to bridge the browser to the scanner.

put cursor in the form field

Are you asking how you can do that?

window.addEventListener("load", 
      function () {
         document.getElementById("your_input_field").focus();
      }, false);

...or is that what you did already?

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • i did already that one brother but the problem here is client wants me to make the scanner work with out putting cursor in the field is there any way of doing that can you please let me know that would be great – user1122486 Dec 30 '11 at 13:45
0

I don't know why everyone is so mad in this thread. Like you said, the common configuration is like a keyboard. I'd use a regular old text field and attach a default action to it like you're submitting a form.

user1119648
  • 531
  • 1
  • 5
  • 16
0

I have experience with barcode scanners. You answered the question yourself: the scanner will deliver the number of the barcode as if it were typed on a keyboard, followed by a return. This is how it works. If you want it to work differently you would have to write yourself a driver for the scanner.

The problem is not with the scanner, it does it's job. What you need to do is find a way to ensure the form field is preselected, and your javascript solution sounds like a good way of doing that.

Although the best solution of all would be a custom made app, which will accept the input from the barcode and then do whatever you want to be done with it (such as POST it somewhere). This would be a desktop app, and would not be difficult to write for an experienced programmer.

Alasdair
  • 13,348
  • 18
  • 82
  • 138