You are viewing limited content. For full access, please sign in.

Question

Question

Using barcode scanner to populate form data

asked on February 11, 2016

We are looking to use Laserfiche forms to enter labor.  We have 5 fields in the form.  The same five fields of form data is stored in the barcode.  When I place my cursor into the first field and scan the barcode, all the data fills into that one field.  I am uncertain how to separate the data so each piece goes into the 5 separate fields.

 

Can this be done?

0 0

Replies

replied on February 11, 2016 Show version history

Hi Jason,

If your barcoded data has either a known and constant format (e.g. the first field is always 5 digits, the second is always 3 letters, etc.) or a delimiter between fields such as a comma (Field1,Field2,Field3) you can add JavaScript to the form that will utilize string parsing functions or regular expressions to parse the initial combo-string into its components and write them out to the Forms fields.

The following example JavaScript code assumes the comma delimited scenario, and sequentially numbered element ID's (q1, q2, q3, etc.) for the forms fields.

$(document).ready(function () {
    $('#q1 input').change(function() {                //Triggers the function when element q1's input value changes
      var fullBarcode = $('#q1 input').val();         //Gets the value of the entire barcode string
      var splitBarcode = fullBarcode.split(',');      //Creates an array of substrings from the barcode string, spit by a comma delimiter
      
      for (var i = 0; i < splitBarcode.length; i++) { //Loops through however many substrings are in the array
        var n = i+1;                                  //Since element IDs start at q1, not q0
          var currentID = "#q" + n.toString();         //Creates the element ID string (sequentially)
        $(currentID + " input").val(splitBarcode[i]); //Writes the i-th substring out to the element's input
      }
    });
});

 

The test form I made for this took the string "Samuel,L.,Carson" as the input into the First field and then wrote each part of my name out to the correct field. The code above works for any number of elements so long as the IDs are sequentially numbered, starting at q1. You can check the element IDs in the CSS and JavaScript section of the Form editor. This is also where the JavaScript goes.

 

 

More information on using JavaScript in Forms can be found at these two links:
https://www.laserfiche.com/support/webhelp/Laserfiche/10/en-US/administration/#../Subsystems/Forms/Content/Forms/Getting-Started-With-JavaScript.htm%3FTocPath%3DForms%7CCreating%2520a%2520Form%7C_____7

 

https://www.laserfiche.com/support/webhelp/Laserfiche/10/en-US/administration/#../Subsystems/Forms/Content/Customizing-Your-Form-Examples.htm

 

Hope that helped!

Cheers,

Sam

0 0
replied on February 21, 2019

Hi Jason,

How are you reading the barcode and inserting the data into a field on the form?

You are not allowed to follow up in this post.

Sign in to reply to this post.