希望这是提出这个问题的正确位置。我对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();
}
非常感谢您花时间阅读本文,如果您能帮助我找到解决方案,还要感谢您。
-Andrew
答案 0 :(得分:0)
想出来。我没有使用getField(“FieldName”)。值来获取值,而是使用.valueAsString来获取它。希望如果有人发现它,这很有用。