I have seen a couple of these questions asked before but I cannot remember if there was ever an answer:

I need to incorporate a barcode scanner for my forms in data entry... I have seen a few responses that we should use javascripts... but where can I find some reference material on javascripting for barcode scanners? Primarily for incorporating a <Tab> instead of a <ENTER> when a field is scanned and/OR how to get the barcode cursor move to the next field if there is no way to set the <ENTER> function of the scanner to a <TAB>.

Any ideas?

    You probably won't find a good one for your specific needs.

    I could be wrong, but I don't believe you can use JavaScript to manipulate the data the barcode reader is sending to the computer before the computer interprets and displays it, which is what I gather you're looking to do.

      Not really. The barcode scanner processes the data just fine (places it in the correcy field with I set the cursor there). The problem is the scanner I use will product a carriage return after the scanning of the barcode. Now there is several way to make the barcode scanner not product the carriage return and emulate something like a TAB.

      I have tried a couple of examples and I can get rid of the carriage return... I just cannot get the cursor to move to the next field. As well, I cannot seem to get the submit button to work correctly after I enter these code strings in the code.

      I have come across a few forum threads that address this very thing and resolve it, but they are typically folks who are javascripting pros (or at least immediate level)... I'm very new to javascripting.

        It might help if you show us the form you're working with (e.g. attach it as a .txt since .html isn't allowed).

        From what I gather, you want the browser to ignore the carriage return that most every barcode scanning software inserts and instead move onto the next field in the form? If so, something like this might work:

        <script type="text/javascript">
        function move(event, obj) {
        	var charCode = (event.which) ? event.which : event.keyCode;
        
        if(charCode == 13) {
        	obj.focus();
        	return false;
        }
        }
        </script>

        Then, your form would look like this:

        Test1: <input type="text" name="foo" onkeydown="return move(event, this.form.foo2)"><br>
        Test2: <input type="text" name="foo2" onkeydown="return move(event, this.form.foo3)"><br>
        Test3: <input type="text" name="foo3">

        Note that I left off the onkeydown event for the last field; if you scanned a barcode in the last field, the carriage return should submit the form instead.

          texmansru47, I just did a barcode project. There was a setting on the barcode device itself where I could make it insert the barcode value then do a TAB automatically. We were using a symbol device, can't remember the model. That was the best solution! Check your scanners configuration settings.

            Write a Reply...