Tags: barcode, based, code, database, form, items, javascript, mysql, oracle, scan, sql

code 128 barcode in javascript

On Database » Oracle

8,828 words with 5 Comments; publish: Wed, 13 Feb 2008 01:46:00 GMT; (25094.73, « »)

hi,i am trying to get a code 128 barcode based on 3 items in a form. it currently wont scan in. i think this is because i have not got a start, stop or check sum. i was wondering how to do this and what the start and stop flags are. the code i have is :<html><head><style>.oracle.itags.org.font-face {font-family:"Code 128"; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 268435456 0 0 -2147483647 0;}</style><script language="JavaScript" type="text/javascript">var i = 1; job_id = 'A' + document.getElementById('P6_item1').value + document.getElementById('P6_item2').value + document.getElementById('P6_item3').value; astr = '<html><head></head>'; astr += '<body lang=EN-GB style=\'tab-interval:36.0pt\'>'; astr +='

'; astr +='
'; astr +='

'; astr += job_id; astr +='

'; astr +='
'; astr +='</body></html>'; document.write(astr); if (!document.all.aDiv.style.filter) document.all.aDiv.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + i + ')'; else document.all.aDiv.filters.item('DXImageTransform.Microsoft.BasicImage').Rotation = i;document.write(job_id);</script></head></html>

All Comments

Leave a comment...

  • 5 Comments
    • Wow. Does this actually produce a barcode? Albeit, maybe an invalid one, but a barcode nonetheless?

      Code 128 barcodes do use a stop and start character. Try using an asterisk.

      Earl

      #1; Fri, 22 Feb 2008 14:28:00 GMT
    • yes it does produce a barcode as long as you have the font installed on ure computer.

      I have tried everything for the start and stop char. ( *, start a, start-a, starta, ^a, stop, 1, 11) i also need to work out some code for the check sum which i have been hard coding for now.

      #2; Fri, 22 Feb 2008 14:29:00 GMT
    • Sorry I can't give you a specific answer, but I do know that a code 128 barcode needs to contain the start and stop characters as well as the check digit - which is based on the start and stop characters and your data for the value itself.

      There are plenty of resources out there (like www.idautomation.com) where you can learn more about it. And it sounds like you're headed down the right path. Good luck with that.

      BTW, I took the easy way out on barcodes and bought a label printing application that I use to grab my Oracle data.

      Earl

      #3; Fri, 22 Feb 2008 14:30:00 GMT
    • hi,

      I have managed to get a working code 128 barcode programmed in javascript.

      it displays the data from three items in my form P6_JOB_ID, P6_STREAM_ID, P6_BATCH.

      it also references images i uploaded (black and white stripes whch i rotated and made the barcode fill down instead of accross)

      The problem I have now is that i am trying to display 27chars which makes my barcode to big. Is there any way of scaling the table and images placed in it? I have tried setting the width and height of the table and this does nothing. I have also tried scaling the images I uploaded before they are placed in the table.

      thanks

      Tom

      #4; Fri, 22 Feb 2008 14:31:00 GMT
    • /*

      <script type="text/javascript">

      {

      value = new Array(

      ' ','!','"','#','$','%',

      '&',"'",'(',')','*','+',

      ',','-','.','/','0','1',

      '2','3','4','5','6','7',

      '8','9',':',';','<','=',

      '>','?','.oracle.itags.org.','A','B','C',

      'D','E','F','G','H','I',

      'J','K','L','M','N','O',

      'P','Q','R','S','T','U',

      'V','W','X','Y','Z','[',

      '\\',']','^','_','`','a',

      'b','c','d','e','f','g',

      'h','i','j','k','l','m',

      'n','o','p','q','r','s',

      't','u','v','w','x','y',

      'z','{','|','}','~','DEL',

      'FNC3', 'FNC2', 'SHIFT', 'CODE C', 'FNC4' , 'CODE A',

      'FNC1'

      );

      code128 = new Array(

      '212222','222122','222221','121223','121322','131222',

      '122213','122312','132212','221213','221312','231212',

      '112232','122132','122231','113222','123122','123221',

      '223211','221132','221231','213212','223112','312131',

      '311222','321122','321221','312212','312212','322112',

      '322211','212123','232121','111323','131123','131321',

      '112313','132113','132311','211313','231113','231311',

      '112133','112331','132131','113123','113321','133121',

      '313121','211331','231131','213113','213311','213131',

      '311123','311321','331121','312113','312311','332111',

      '314111','221411','431111','111224','111422','121124',

      '121421','141122','141221','112214','112412','122114',

      '122411','142112','142211','241211','221114','413111',

      '241112','134111','111242','121142','121241','114212',

      '124112','124211','411212','421112','421211','212141',

      '214121','412121','111143','111341','131141','114113',

      '114311','411113','411311','113141','114131','311141',

      '411131'

      )

      barcode= document.getElementById('P6_JOB_ID').value + document.getElementById('P6_STREAM_ID').value + document.getElementById('P6_BATCH').value;

      barcodeok = (barcode != null);

      if (barcodeok) barcodeok = (barcode != "");

      if (barcodeok) {

      chksum = 104;

      code = barcode;

      m = 1;

      for (i = 0; i < barcode.length; i++) {

      v = -1;

      for (j = 0; j < value.length; j++) {

      if (value[j] == barcode.charAt(i)) {

      v = j;

      }

      }

      chksum += m * v;

      m++;

      }

      chksum = chksum % 103;

      barcode = barcode + value[chksum];

      wstr = "";

      for (i = 0; i < barcode.length; i++) {

      v = -1;

      for (j = 0; j < value.length; j++) {

      if (value[j] == barcode.charAt(i)) {

      v = j;

      }

      }

      wstr += code128[v];

      }

      wstr = "211214" + wstr + "2331112";

      l = "\x3C"; g = "\x3E";

      astr = l + 'html' + g + "\n" + l + 'head' + g + "\n" +

      l + 'title' + g + code + l + '/title' + g + "\n" +

      l + '/head' + g + "\n";

      astr += l + 'body' + g + "\n";

      astr += l + 'table border=0 cellspacing=0 cellpadding=0'+ g + "\n" +

      l + 'tr' + g;

      for (i = 0; i < wstr.length; i++) {

      for (j = 0; j < wstr.charAt(i); j++) {

      astr += l + 'tr' + g + l +

      'img src="/app/links/?src=#WORKSPACE_IMAGES#Pbc-' +

      (1 - i%2) + '.png" alt="' +

      (1 - i%2) + '"' + g + l + '/tr' + g + "\n";

      }

      }

      astr += l + '/tr' + g + "\n";

      // astr += l + 'caption' + g + code + l + '/caption' + g + "\n";

      astr += l + '/table' + g + "\n" + l + '/body' + g + "\n" + l + '/html' + g + "\n";

      document.write(astr);

      }

      }

      // -->

      */

      #5; Fri, 22 Feb 2008 14:32:00 GMT