These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Dynamic barcode data length?

lisamwise
Registered: May 18 2009
Posts: 22
Answered

Does anyone know how to dynamically set the data length of a barcode based on the input of another field?

e.g. I have a form that converts a credit card number to a barcode. If the card is Visa, Mastercard, or Discover, I need the barcode to 16 digits. If it is American Express, I need it to be 15 digits. I have the card type as series of check boxes.

My Product Information:
LiveCycle Designer, Windows
hcorbin
Registered: Aug 11 2009
Posts: 57
Hi,

I suggest using radio buttons instead of check boxes. Radio buttons are mutually exclusives. Here is an example of a script living in the change event of the RadioButtonList:

if (this.rawValue == 4)Code3of9BarCode1.ui.barcode.dataLength = "15"; // MC, Visa, DiscoverelseCode3of9BarCode1.ui.barcode.dataLength = "16"; // Amex

Here, the barcode is a sibling of the radio button list. I'm not very familiar with barcode fields and don't know if there is any counter indication in doing this but play with it and see if that works for you.

Hélène
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
I would use radio buttons not check boxes for this.
The you can add a script to change the barcode data length.

 Form1.#subform[0].Creditcard::change - (JavaScript, client)if (thid.rawValue == "1"){Code128BarCode1.ui.barcode.dataLength = "16";Code128BarCode1.rawValue = "1234567890123456";}if (this.rawValue == "2"){Code128BarCode1.ui.barcode.dataLength = "15";Code128BarCode1.rawValue = "123456789012345";}

Sample form:
https://share.acrobat.com/adc/document.do?docid=66a4738e-7150-443f-b0df-efa75c99b741

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

lisamwise
Registered: May 18 2009
Posts: 22
Thanks, that worked great. I ended up leaving my check boxes, though because I tried to do it with a radio group and it didn't work. I just applied the script to the change event for each check box.

Here's the code I ended up using:
if (Card_type.rawValue != 0) {if (Card_type.rawValue == 4) {cc_barcode.ui.barcode.dataLength = "15";cc_barcode.rawValue = "123456789012345";}else {cc_barcode.ui.barcode.dataLength = "16";cc_barcode.rawValue = "1234567890123456";}}

Is it possible to add a line to the code above do the same type of thing to change the comb for a numeric field? I have tried using the suggestions from the LiveCycle syntax reference cc_number.resolveNode("ui.#textEdit.comb").numberOfCells = "16";
but it doesn't work.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
If you use a numeric field you can use:
cc_number.ui.numericEdit.comb.numberOfCells = "16";
for a text field you use:
cc_number.ui.textEdit.comb.numberOfCells = "16";

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

lisamwise
Registered: May 18 2009
Posts: 22
Once again, thank you so much Marcus!