首先我要告诉你我不是程序员。我在 Adobe LiveCycle 中设计了一个表单,但现在我想将某些字段的值包含到具有特定分隔符的纸质表单条形码中。我的问题是,当字段留空时,我不想得到“null”。我需要该字段保持为空,并且值字符串继续下一个字段。这是我在将 2 个字段留空后扫描条形码时得到的结果。 “1个字段|2个字段^3个字段|4个字段|null| null|最后一个字段|
但这需要得到:
“1个字段|2个字段^3个字段|4个字段|||最后一个字段|
空行用于其他目的”
任何帮助将不胜感激。我一直在寻找答案,但无法根据我的需要调整找到的答案。
这是我正在使用的代码:
// This function ensures that the barcode will update
// when a change is made to any field on the form.
function depends(node)
{
for (var i = 0; i < node.nodes.length; ++i)
{
var child = node.nodes.item(i);
if (child.isContainer)
depends(child);
}
}
// Return a field surrounded by quotes and followed with a separator
function fmtField(fieldName, separator)
{
var str = fieldName.rawValue+ separator;
return str;
}
// Force all fields in the form to be updated in the dataset
depends(xfa.form);
// Generate the CSV string that will be encoded in the barcode
var bar = "|";
var eso= "^"
var newLine = "\n";
var s = fmtField(accountNum, bar);
s += fmtField(formerFirstName, eso);
s += fmtField(formerMiddleInitial, bar);
s += fmtField(formerLastName, bar);
s += fmtField(newFirstName, bar)
s += newLine
s += fmtField(newMiddleInitial, bar);
s += fmtField(newLastName,bar);
s += newLine
s += "Empty line for other purposes"
// Assign the string to the barcode for encoding
this.rawValue = s ;
最佳答案
试试这个:
function fmtField(fieldName, separator)
{
var str = {};
if(fieldName.rawValue == null){
str = "";
}
else{
str = fieldName.rawValue+ separator;
}
return str;
}
关于javascript - 避免在纸质表单条形码 LiveCycle Javascript 上出现 "Null",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30530405/