I am currently developping a web application that needs to be able to read datamatrix codes that contain multiple values ( all seperated by pipes ). This code contains about 70-80 characters and I only need the first 10.
I am using a simple javascript regex that allows me to detect when those 10 characters are entered and I then trigger a postback.
So that is how it works:
When I scan the code and see that I have the part I need, I trigger a postback, do some logic on the backend, and then, put back the focus on the input used for scanning so that the user can scan again.
The problem is:
When I set the focus back to the input, the scanner continues to output the rest of the previous datamatrix code ! ( the scanner takes about 1-1.2 seconds to scan the complete code ), so if my backend logic is faster than that, it won’t be finished, even after my postback. )
My question is:
Is there something I can do about it ?
Here are two of the solutions that I have but that are not ideal at all:
- Use some sort of a javascript timer that would allow me to detect whenever the scanner has finished ( the problem is that, I don’t want to wait for the scanner to finish before scanning a new code )
- Put another datamatrix that contains only this value ( This would be my last solution since it would impact a lot of things )
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Although I would have liked to find an in-code solution, I found another solution.
I found out that I could change the scanner’s speed using a configuration page. I put it at “fast” and now I receive the string almost all at once. ( Not event .2 seconds )
I just don’t know why fast isn’t the default option..
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0