471,832 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,832 software developers and data experts.

Scanning bar code <GS> into web form

I have a problem using a bar code scanner into a text area.

I found on this forum someone with the same problem as me, except he thought the javascript wasn't finding the <GS> character \1D.

The problem is, the scanner isn't scanning it into the text area. Yet it does scan into Text Pad and when cutting and pasting it into the text area, javascript does find it.
Just can't scan it directly into the text area.
I have tried changing the META TAG and the form parameters in the html.
If Paul Jørstad is there is would like to know how he solved the problem.
Thanks, Pam.
Apr 22 '09 #1
8 5143
1,134 Expert 1GB
Browsers automatically remove certain characers from html content.
For example, if you send "Hello world" with 20 spaces inbetween the two words into a <textarea> from script and then read back the contents of the <textarea>, the result would be

"Hello World" with only 1 space. The other 19 were removed by the browser when the script added it.

However, if you do the same thing into an <input type='text'> then you get back what was put in.
Have you tried using an <input> instead of a <textarea>?
Apr 23 '09 #2
Hi Delerna, but i just tried the input and that too, did not have the character when i scanned directly to it.
And when i scan to text pad, the character is there, and when i paste into the input the javascript finds it.
Thanks, Pam.
Apr 23 '09 #3
16,027 Expert Mod 8TB
Perhaps you need to check the character encoding on the page.
Apr 25 '09 #4
Any suggestions? I have tried
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<textarea name='txt1' id='txt1' rows="10" cols="120" accept-charset="UTF-8"
<form id="form1" name="form1" accept-charset="UTF-8"
Apr 27 '09 #5
16,027 Expert Mod 8TB
Perhaps you could try a different browser or scanner and see if that makes a difference.
Apr 28 '09 #6
1,134 Expert 1GB
My limited experience with barcode scanners showed they generally send a sequence of characters as though they were entered directly from the keyboard, is that what yours is doing?

How are you getting the entry from the input/textarea?

I'm thinking that if you use the onkeydown event of the
<input type=text onkeydown="OnKeydownEventOccured()">
that the event might get called for each individual character sent from the scanner and you might get all the characters that way.

test the theory with something like this
Expand|Select|Wrap|Line Numbers
  1. function OnKeydownEventOccured()
  2. {   alert(window.event.keyCode);
  3. }
You may already be doing something like this. If so ignore my post :)

Good luck, there must be some logical explanation for this, just have to find it.

Incidentally, I think that copy paste of the sequence from notepad might put the whole string into the input/textarea in one hit as opposed to 1 character at a time when entered directly from the scanner. Perhaps this is why the character is dropped when entered from the scanner and not when it is entered from a paste operation?
Apr 28 '09 #7
Hi Delerna, using your function, i was able to concatenate all the chars and ascii values together. And it seems there is a character there but not the GS. it is ascii 17 and 221.
It was suggested to look for any non numeric character so I did that, but after the form is submitted they disappear. So I may have to do something client side.
May 6 '09 #8
1,134 Expert 1GB
sounds like a plan.........
May 6 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by nyso | last post: by
4 posts views Thread by Paul Jørstad | last post: by
3 posts views Thread by Martin | last post: by
8 posts views Thread by Sam Halliday | last post: by
reply views Thread by John | last post: by
4 posts views Thread by GS | last post: by
7 posts views Thread by creative1 | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.