JsBarcode icon indicating copy to clipboard operation
JsBarcode copied to clipboard

Dynamic Barcode generation

Open SCOMAC1959 opened this issue 7 years ago • 1 comments

Is it possible to replace the barcode information with information from another div?

Something like: JsBarcode("#barcode3", "SK000007", { format: "CODE39", displayValue: true, });

Replacing the SK000007 with content of another div such as this jQuery code?: $('#div2').html($('#div1').html());

If so how might that be done?

SCOMAC1959 avatar Dec 08 '17 13:12 SCOMAC1959

This is what I use to dynamically generate sheets of different barcodes.

Each item is added with an HTML template with the following. I replace the #UPC# with the actual value when generating the file.

<svg class="barcode"
  jsbarcode-format="upc"
  jsbarcode-value="#UPC#"
  jsbarcode-textmargin="0"
  jsbarcode-fontoptions="bold">
</svg>

Then at the end of the file I added this simple script line which initializes all .barcode classes.

<script>
    JsBarcode(".barcode").init();
</script>

laferil avatar Jan 22 '18 18:01 laferil