Print Page | Close Window

TypeError: " is undefined "

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=1441
Printed Date: 26 Apr 2019 at 11:18am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: TypeError: " is undefined "
Posted By: lindaelise
Subject: TypeError: " is undefined "
Date Posted: 07 Feb 2015 at 11:34pm

Hello,

 

I am getting the following error:

 

TypeError: global.srchVals[PMItms[j]] is undefined

 

 

The code is failing at this line:

 

 

global.srchVals[PMItms[j]].srchPgs = PMPgs;

 

 

 

Here is more of the code up to the point where it fails:

 

 

function subSrchValPM() {

    var srchThisStr = "";
  srchThisStr = this.getField(1).valueAsString;
var srchThisArr = srchThisStr.replace(/\s/g,"").split(",");
var nNumWords = srchThisArr.length;
var myArr = [];  //var myArr = new Array();
for(i = 0; i <= nNumWords; i++){  //for (var i in srchThisArr)
       myArr.push("" + srchThisArr);
    //return myArr;
   }


global.srchVals = [{}]
for (i = 0; i<= nNumWords; i++) {
  global.srchVals = {srchTrm: trim(""+myArr).valueAsString, mode: 0, results: []}; //

}
 

// Payor Mix
var PMAddItms = "";
var PMLstItms = "";
for (var i=1; i<= nNumWords; i++) {
      global.srchVals.name = "Payor Mix";
   global.srchVals.mode = 0;

  PMAddItms = i;
  
   if (i < nNumWords) {
   PMLstItms = PMLstItms + PMAddItms + ",";
  } else {
   PMLstItms = PMLstItms + PMAddItms;
  }


 
}
  var PMItms = [PMLstItms];
 


for (var i in global.srchVals) {
  global.srchVals.srchPgs = [];
  global.srchVals.matchTerm = getMatchTerm(global.srchVals.srchTrm, global.srchVals.mode);
}
 
this.closeDoc(true);

var t = app.thermometer;
t.begin();

t.text = "Processing bookmarks...";
var PMPgs = [];
for (var i=0; i<global.mainDoc.bookmarkRoot.children.length; i++) {
  if (global.mainDoc.bookmarkRoot.children.name.indexOf("Payor Mix")!=-1)  {
   PMPgs = getBookmarkRange(global.mainDoc, global.mainDoc.bookmarkRoot, i); 
   //PMPgs = PMPgs.slice(PMPgs.length -1);  // Use first page of the bookmark
   for (var j in PMItms)
    global.srchVals[PMItms[j]].srchPgs = PMPgs;  // Here is where the error happens
  }
}

 

....... the rest of the code ......

 

 

 

 

}

 

Why am I getting an "is undefined" error?

 

Thanks

 

Linda




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net