Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to create a custom barcode on End Message (or anywhere I suppose)

  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 5 months ago #160074 by blocka
I had a requirement to generate a unique barcode at the completion of response submission.

Accomplishing this was easy, so I thought I'd share it in case anyone else needs to do this.

1. Visit lindell.me/JsBarcode/ to see all the options available

2. Create a LS custom template, and in the startpage.pstpl within the <head> tag, add:
Code:
<script src="https://cdn.jsdelivr.net/jsbarcode/3.6.0/JsBarcode.all.min.js"></script>

(you can also place this JS locally within your template's scripts folder if you prefer)

3. Within the End Message (in source view), place the following where you want the bar code to be displayed:
<svg id="barcode"></svg>

and then insert :


<script>JsBarcode("#barcode", "{SID}{SAVEDID}");</script>

When your survey is Activated, {SID} returns your survey ID, and {SAVEDID} returns the response key. Pass this to the JS script to generate your bar code, and you'll have a unique bar code that is comprised of the surveyID plus the response ID.
The following user(s) said Thank You: DenisChenu, Joffm
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose