Hello,
I would like to show in a handlebards document the form identifier number as a barcode.
My first option is to add the code directly into the document and show the identifier as a barcode. I found some scripts online, but when I use them in the TrueContext editor, they do not work. Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Barcode Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.7/handlebars.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspdf@2.4.0/dist/jspdf.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/JsBarcode.all.min.js"></script>
</head>
<body>
<script id="barcode-template" type="text/x-handlebars-template">
<svg id="barcode"></svg>
<p>{{string}}</p>
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const templateSource = document.getElementById('barcode-template').innerHTML;
const template = Handlebars.compile(templateSource);
// Example string to be converted into a barcode
const context = {
string: "123456789012"
};
const html = template(context);
document.body.innerHTML += html;
// Generate the barcode
JsBarcode("#barcode", context.string, {
format: "CODE128", // You can change the format as needed
width: 2,
height: 100,
displayValue: true
});
});
</script>
</body>
</html>
Do this kind of scripts work in the handlebars editor? If so, how?
My second option would be to have a barcode question in the form that gets somehow the identifier of the form and then show it in the doc. Is it possible? If so, how?
------------------------------
Alicia Rico
CI
Johnson Controls
------------------------------