Skip to content

Commit c306fdc

Browse files
committed
Update scan-and-search.html
1 parent 5e717eb commit c306fdc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

barcode-scanner-api-samples/scan-single-barcode/scan-and-search.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Scan & Search with BarcodeScanner</title>
8-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.3000/dist/dbr.bundle.js"></script>
8+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.3000/dist/dbr.bundle.js"></script>
99
</head>
1010

1111
<body>
@@ -19,7 +19,7 @@ <h3></h3>
1919
<div class="corner br"></div>
2020
</div>
2121
</button>
22-
<input type="text" id="text-input" placeholder="Search By Barcode or Text" />
22+
<input type="text" id="text-input" placeholder="Enter any UPC, EAN, or ISBN number" />
2323
<button id="search-btn" aria-label="Search">
2424
<div class="search-icon"></div>
2525
</button>
@@ -49,8 +49,10 @@ <h3></h3>
4949
scanBtn.disabled = true;
5050
const result = await barcodeScanner.launch();
5151

52-
if (result.barcodeResults[0])
52+
if (result.barcodeResults[0]) {
5353
searchResult.value = `Barcode Text to Query from Database: \n\n${result.barcodeResults[0].text} \n\n-------------------\n\nProduct name: xxx \n\nBrand: xxx \n\nCategory: xxx \n\nPrice: xxx \n\nDescription: xxx`;
54+
inputBox.value = result.barcodeResults[0].text;
55+
}
5456

5557
scannerContainer.style.display = "none";
5658
scanBtn.disabled = false;
@@ -63,6 +65,7 @@ <h3></h3>
6365
});
6466

6567
searchBtn.addEventListener("click", () => {
68+
if(!inputBox.value) return;
6669
searchResult.value = `Text to Query from Database: \n\n${inputBox.value} \n\n-------------------\n\nProduct name: xxx \n\nBrand: xxx \n\nCategory: xxx \n\nPrice: xxx \n\nDescription: xxx`;
6770
});
6871
};

0 commit comments

Comments
 (0)