/    Sign up×
Community /Pin to ProfileBookmark

Barcode Scanner using JS?

Could someone direct me on the use of a barcode laser scanner and JavaScript.

I have a guy that currently uses a barcode scanner gun real fast to populate a row on an Excel spreadsheet with the item number scanned every time he clicks the scanner.

I need to duplicate this process with a web form and a “textarea” box in HTML. I was wondering if anyone knew how to do this with JavaScript. Every time he scans a barcode it needs to populate the value in the textarea and then JavaScript moves the cursor to the next line in that box ready to put in another one. As fast as he scans these barcodes it puts an item on another line.

(Then on the backend using server side scripting I will load these values as separate records in a table using the line break as the delimiter.)

Do you figure this scanner setup as describe just do this with our JavaScript. It seems like it is popping the value in Excel and moving to the next row (does this mean the scanner is producing doing an “Enter” with the keyboard automatically?) Or will I need so JavaScript I am not familiar with to do this?

Any suggestions?

Thanks

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@ExuroMar 19.2005 — I researched a little bit into barcode scanners earlier this year, and from what I can tell they act just like a keyboard input. The barcode scanner may send an "enter" character after reading the barcode in, but it may not. Try opening Notepad or some other text editor and see what happens when you read in multiple barcodes in a row. If it doesn't, then I would think all the barcodes should contain the same number of characters. Using this fact you could make use of an event like [FONT=courier new]onkeypress[/FONT] in your [FONT=courier new]<input>[/FONT] fields, and when the value reaches a specified length you can shift the cursor to the next field using the [FONT=courier new]focus()[/FONT] method.
Copy linkTweet thisAlerts:
@pelegk1Mar 20.2005 — i dont understandexeclly what yo ask for

but a year ago i have found a JS barcode for 10$ on the net

and not long ago i have seen a bar code maye out in PHP.
Copy linkTweet thisAlerts:
@marms767authorMar 20.2005 — Thanks Exuro

You have the right idea, but instead of seperate fields to focus(); on it would need to be the "next line" in one <textarea></textarea> box. The reason for this is that this guy could be scanning in 100 or more items and I would have no idea to a set number of fields to on the page.

Would you have an idea how to use JavaScript to go to the next line on the same field if the scanner does not do a "Enter" on an item.

(I will have to go "on site" to test his scanner at a later date, but I need to tell him if I can do his job or not before then.)

Thanks
Copy linkTweet thisAlerts:
@Khalid_AliMar 20.2005 — you will need to write an application(or may be bar scanner already provides you with one) that does it for u.

As far as JavaScript is concern it can not work directly with any of such devices.

You can change lines using JS in text area but thats the little problem, you first need to figure out how to get data to HTML page in question from bar code scanner
Copy linkTweet thisAlerts:
@nusenseMar 20.2005 — Dig deeper and you will find that theirs a way of importing and accessing data in an Excel sheet, so it would be a case of writing a script to access the data delivered via an active X control.

Javascript gets blown over with usual comments of it cant or a flat no it cant and I have seen myself from browsing the forums that Javascript has got access to resources that are often overlooked like the power of the access of active X.
Copy linkTweet thisAlerts:
@Khalid_AliMar 20.2005 — using active x control does not mean that JavaScript has this ability to do something itself. As a amtter of fact using ActiveXControl is one of the worst thing that one can do to make their servers vilnerable to any malware or mal intenttions.

There has to be a server side solution (and I know thre are depending upon bar code scanner tools) for such purposes. Just hope that people some day will learn that a suggestion just for the sake of a suggestion doesn't really help.
Copy linkTweet thisAlerts:
@ExuroMar 21.2005 — [i]Originally posted by Khalid Ali [/i]

[B]As far as JavaScript is concern it can not work directly with any of such devices.[/B][/QUOTE]
Like I said, I'm pretty sure the scanner acts just like a keyboard and just sends the characters it reads into the text buffer, so if you had a web application open with the focus on a textarea then it would probably write the characters right into the textarea.

Anyway, as for putting a new line between each barcode, you could probably implement the same [FONT=courier new]onkeypress[/FONT] event to monitor the length of the textarea, and every time an entire barcode is entered just add a new line like this:
txtBarcodes.value += 'n';
Copy linkTweet thisAlerts:
@jbotMar 21.2005 — [i]Originally posted by Exuro [/i]

[B]Like I said, I'm pretty sure the scanner acts just like a keyboard and just sends the characters it reads into the text buffer, so if you had a web application open with the focus on a textarea then it would probably write the characters right into the textarea.[/code] [/B][/QUOTE]


yes, but a browser cannot communicate with that sort of device. you'd need an ActiveX control or a Java applet to do that. Excel can do it only because it has an API which allows it. browsers don't.
Copy linkTweet thisAlerts:
@Khalid_AliMar 21.2005 — [i]Originally posted by jbot [/i]

[B]yes, but a browser cannot communicate with that sort of device [/B][/QUOTE]


And thats what my point is.

If you are to do something like that, then might as well do it in a way thats more secure and elegant.

Use a stand alone app that gets the input stream from the scanner and posts it to the webpage or use a server side application that does the same. Using ActiveX Controls is one of the worst thing for any web page.
Copy linkTweet thisAlerts:
@marms767authorMar 22.2005 — Thanks for everyone's input.

I built a test web form for the client with a <textarea></textarea> box and had it email me the results so I could see the data format.

He is using a "Keyboard Wedge Scanner" and this one enters the item code and produces a line break/return after each item scanned just like I need it to. Now I for sure have the delimiter I need put each scanned item into it's own record.

No JS solution needed.

Thanks Again.
×

Success!

Help @marms767 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...