繁体   English   中英

从PDF字段到JavaScript变量的前导零

[英]Leading zeros from PDF field to javascript variable

希望这是问这个问题的正确地方。 我对javascript完全陌生,但是看到它与我所写的其他语言的相似之处,到目前为止,这一直很容易。

我正在为用户填写网格后单击的按钮编写脚本。 该脚本遍历网格中的字段,获取信息并生成电子邮件。 然后,它发送出一个mailto:命令,其中包含生成的信息,这比用户必须自己键入电子邮件要容易得多。 我遇到的问题是,该字段的条件之一是Tax ID,有时可以以零开头,当我将该字段值分配给变量时,它会删除前导零。 如何获取javascript以保持前导零? 我尝试在开始时用“”声明变量,以强制其将变量识别为字符串,但这似乎不起作用。

这是我的代码:

if(this.getField("ProviderOne").value != "")
{
    // This is the form return email. Its hardcoded
    // so that the form is always returned to the same address
    var cToAddr = "blank@blank.org";

    // First, get the client CC email address
    var cCCAddr = "blank@blank.com";



    var pOneTaxID = new String(this.getField("ProviderOneTaxID").value); //tring to force string value

    // Set the subject and body text for the email message
    var ProviderOne = this.getField("ProviderOne").value + " NPI:" + this.getField("ProviderOneNPI").value + " Tax ID:" + pOneTaxID;

    var ProviderTwo = this.getField("ProviderTwo").value + " NPI:" + this.getField("ProviderTwoNPI").value + " Tax ID:" + this.getField("ProviderTwoTaxID").value;

    var ProviderThree = this.getField("ProviderThree").value + " NPI:" + this.getField("ProviderThreeNPI").value + " Tax ID:" + this.getField("ProviderThreeTaxID").value;

    var ProviderFour = this.getField("ProviderFour").value + " NPI:" + this.getField("ProviderFourNPI").value + " Tax ID:" + this.getField("ProviderFourTaxID").value;

    var ProviderFive = this.getField("ProviderFive").value + " NPI:" + this.getField("ProviderFiveNPI").value + " Tax ID:" + this.getField("ProviderFiveTaxID").value;

    var cSubLine = this.getField("ProviderOne").value + " ERA setup for [BLANK]";

    var cBody = "To [BLANK], \n \nPlease enroll the following providers to receive [BLANK] through [BLANK] under [BLANK]: \n \n";

    if(this.getField("ProviderOne").value != "")
    cBody += "1. " + ProviderOne + "\n";

    if(this.getField("ProviderTwo").value != "")
    cBody += "2. " + ProviderTwo + "\n";

    if(this.getField("ProviderThree").value != "")
    cBody += "3. " + ProviderThree + "\n";

    if(this.getField("ProviderFour").value != "")
    cBody += "4. " + ProviderFour + "\n";

    if(this.getField("ProviderFive").value != "")
    cBody += "4. " + ProviderFive + "\n";

    cBody += "\n Thank you,\n" + this.getField("ProviderOne").value;

    app.mailMsg({bUI: true, cTo: cToAddr, cCc: cCCAddr, cBCc: "", cSubject: cSubLine, cMsg: cBody});
}
else
{
    app.alert("Please enter at least one payer into the grid above.", 1, 0, "Unfilled Form");
    this.getField("ProviderOne").setFocus();
}

非常感谢您抽出宝贵的时间阅读本文档,如果您能帮助我找到解决方案,请多谢您。

-安德鲁

弄清楚了。 我没有使用getField(“ FieldName”)。value来获取值,而是使用.valueAsString来获取它。 希望如果有人在以后找到它,这将很有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM