Archive | Barcode RSS feed for this section

BARCODE Reader and JavaScript

19 Jun

Barcode reader is a common tool used for different type of authentication. Recently I worked in Event management software for a local community. They are going to provide a membership card with a barcode and on the Event venue they want to use it for authentication.

There are some interactive barcode reader that can read the code and put it where your computer is focused and interesting thing is the barcode reader add an ENTER KEY STROCK after putting the coderin the focused field.

I completed the work really in an easy way. I used HTML, JAVASCRIPT and XML . But there are some small issues I want to share with you because first time I fall in a trap with JavaScript. When barcode scanner reader the code and put it in the focused input box then it become difficult to track it with JavaScript event tracker like “onblur”, “onchage” , “onfocus” etc.

It is easy to solve the problem if we put input box in a <form> element because barcode press an enter after reading the code i.e. it submit the form after retrieving the code. See the following code.

<form onsubmit = “return ini()”>

<input type=”text” id=”code_read_box” value=”” />

</form>

So, each time function “ini()” got called when the barcode complete the scan and put the code. Now we can use the following JavaScript function to get the code:

function ini()
{

// Retrieve the code
var code =document.getElementById (‘code_read_box’).value;

// Return false to prevent the form to submit
return false;

}

I used MOTOROLA LS-2208 as a barcode scanner and it worked fine.

Follow

Get every new post delivered to your Inbox.