表單中添加條碼的(de)解決方案
1、首先下載此壓縮包解壓之(zhī)後得到(dào)兩個(gè)JS文件,将此文件拷貝至C6安裝目錄下的(de)C6\Jhsoft.Web.module\fceform\js文件夾下
2、在(zài)需要(yào / yāo)實現條碼生成的(de)表單中添加此JS
3、在(zài)自定義函數中添加如下代碼,注意txtSN是(shì)當前表單中根據此字段的(de)内容生成的(de)條碼,實際運用過程中請根據需要(yào / yāo)進行修改:
function generateBarcode(){
var value = document.getElementById("txtSN").value;
var btype = $("input[name=btype]:checked").val();
var renderer = $("input[name=renderer]:checked").val();
var quietZone = false;
if ($("#quietzone").is(':checked') || $("#quietzone").attr('checked')){
quietZone = true;
}
var settings = {
output:renderer,
bgColor: $("#bgColor").val(),
color: $("#color").val(),
barWidth: $("#barWidth").val(),
barHeight: $("#barHeight").val(),
moduleSize: $("#moduleSize").val(),
posX: $("#posX").val(),
posY: $("#posY").val(),
addQuietZone: $("#quietZoneSize").val()
};
if ($("#rectangular").is(':checked') || $("#rectangular").attr('checked')){
value = {code:value, rect: true};
}
if (renderer == 'canvas'){
clearCanvas();
$("#barcodeTarget").hide();
$("#canvasTarget").show().barcode(value, btype, settings);
} else {
$("#canvasTarget").hide();
$("#barcodeTarget").html("").show().barcode(value, btype, settings);
}
}
4、在(zài)表單的(de)HTML中添加如下代碼:
5、表單打開函數中添加條碼生成函數:
6、實現效果如下:
7、條碼掃描: