I'm using a Zebra DS9908 scanner to scan a bar code and put the data on an HTML page. What element should I use to preserve all input characters? I've tried both a <div>
and <textarea>
, but in both cases the line feed characters between the records in the bard code data are being stripped off. I've tried "white-space: pre-wrap", but that has no effect.
Note, the scanner works via keyboard input. When I scan the barcode into notepad, it works fine.
UPDATE 1
The data is driver's license data. The bar code is PDF417 and the data formats are from AAMVA. A sample of the data is below. I don't have any questions on that. I'm trying to find a way to stream ALL characters to an HTML element, including line feeds. Line feed are used to separate the fields.
ANSI 6360100102DL00390183ZF02220047DLDAAJDOE,JOHN
DAG555 5th St
DAIMIAMI
DAJFL
DAK38451
DAQH50000000000
UPDATE 2
html
<div id = "scannedData" contenteditable="true" style="width:250px;height:750px; outline: 5px dotted green; white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word;-webkit-line-break:normal;"></div>
javascript
document.addEventListener('keypress', keypressHandler);
function keypressHandler(event) {
var scannerOutput = document.getElementById('scannedData');
if (event.length != 0) {
if (event.key == 'Enter') {
scannerOutput.innerHTML += "<BR>";
parseDriverLicense();
} else {
scannerOutput.innerHTML += event.key;
}
}
}
tag for each line. I don't remember if all the extra css is needed on the div. I'll check tomorrow. – Mr Smith Mar 22 '23 at 19:25