By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,257 Members | 928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,257 IT Pros & Developers. It's quick & easy.

Scanning bar code <GS> into web form

P: 4
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.
http://bytes.com/groups/javascript/9...rm-input-field

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
Share this Question
Share on Google+
8 Replies


Delerna
Expert 100+
P: 1,134
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

P: 4
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

acoder
Expert Mod 15k+
P: 16,027
Perhaps you need to check the character encoding on the page.
Apr 25 '09 #4

P: 4
Any suggestions? I have tried
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
also
<textarea name='txt1' id='txt1' rows="10" cols="120" accept-charset="UTF-8"
also
<form id="form1" name="form1" accept-charset="UTF-8"
Apr 27 '09 #5

acoder
Expert Mod 15k+
P: 16,027
Perhaps you could try a different browser or scanner and see if that makes a difference.
Apr 28 '09 #6

Delerna
Expert 100+
P: 1,134
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. }
  4.  
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

P: 4
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

Delerna
Expert 100+
P: 1,134
sounds like a plan.........
May 6 '09 #9

Post your reply

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