Scanning bar code <GS> into web form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pinkskink
    New Member
    • Apr 2009
    • 4

    #1

    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.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    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>?

    Comment

    • pinkskink
      New Member
      • Apr 2009
      • 4

      #3
      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.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Perhaps you need to check the character encoding on the page.

        Comment

        • pinkskink
          New Member
          • Apr 2009
          • 4

          #5
          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"

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Perhaps you could try a different browser or scanner and see if that makes a difference.

            Comment

            • Delerna
              Recognized Expert Top Contributor
              • Jan 2008
              • 1134

              #7
              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="OnKe ydownEventOccur ed()">
              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
              [code=jscript]
              function OnKeydownEventO ccured()
              { alert(window.ev ent.keyCode);
              }
              [/code]

              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?

              Comment

              • pinkskink
                New Member
                • Apr 2009
                • 4

                #8
                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.

                Comment

                • Delerna
                  Recognized Expert Top Contributor
                  • Jan 2008
                  • 1134

                  #9
                  sounds like a plan.........

                  Comment

                  Working...