AJAX DBLookup - Getting "Object doesn't support this property or method" error

Hi,

I am trying to implement the AJAX version of a DBLookup within a button on a web-enabled form, and I am getting the “Object doesn’t support this property or method” error. The error message references line 166, but I am not sure how it determines line 166?

What does this error mean? Any help would be greatly appreciated.

Here is the HTML code for the form:

Document Search

Area:

Document Type:

Document:

<select name=“Sel_Doc” onchange="document.forms[0].B1.click();

document.forms[0].B2.click()

_doClick(‘$Refresh’, this, ‘_self’, ‘#_RefreshKW_Sel_Doc’)" id=“f3”>

---Please Select--- ENVH&SEAP.A Emergency Action Plan - Spills ENVH&SEAP.B Emergency Action Plan - Electrical ENVH&SEAP.C Emergency Action Plan - Fires and Explosions ENVH&SEAP.D Emergency Action Plan - Natural Gas and Propane ENVH&SEAP.E Emergency Action Plan - Natural Disasters

<input type=“button” onclick="server = (window.location.hostname);

pathname = (window.location.pathname);

pathname = pathname.substring(0,(pathname.lastIndexOf(‘.nsf’)+5));

KEY = document.forms[0].Sel_Doc.value

//this is the call to the function

var a = dbLookup("","","(LookupUnID)",KEY,2)

var splitVal = a.split(", ")

for (i=0;i<splitVal.length;i++)

{

alert(splitVal[i])

document.forms[0].testfld.value = splitVal[i]

}

//DBLookup

function dbLookup(server,path,view,key,column){

xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");

xmlDoc.async = false;

var pos=0;

currURL = (document.location.href).toLowerCase();

if (trim(server) == "") {

pos = currURL.indexOf(‘://’);

if (pos < 0 )

server = "http://apps1/ISOx6&quot; // PUT YOUR SERVERNAME HERE

else

{

pos += 3;

pos = currURL.indexOf(‘/’, pos);

server = currURL.substring(0, pos)

}

}

if( trim(path) == "" )

{

if( pos > 0 )

{

newPos = currURL.indexOf(‘.nsf’,pos);

if (newPos > 0)

{

path = currURL.substring(pos+1,newPos+4)

}

}

}

//Javascript index starts at 0, so need to decrement the column by -1

if( !isNaN(column) )

column -= 1;

vurl = trim(server)+"/"+trim(path)+"/"+view+"?readviewentries&login=1&count=9999&startkey="+key;

xmlDoc.load(vurl);

if (xmlDoc.documentElement == undefined)

{

return("")

}

nodes = xmlDoc.documentElement.childNodes;

temp = new Array(nodes.length);

var j = 0;

for (var i = 0; i < nodes.length; i++)

{

if(nodes.item(i).childNodes.item(0).text==key)

{

temp[j] = nodes.item(i).childNodes.item(column).text;

j++;

}

else

{

break;

}

}

var results = ""

for (var i = 0; i < j; i++)

{

if (i==0)

{

results = temp[i];

}

else

{

results = results + ", " + temp[i];

}

}

return(results);

} //End of dbLookup

//Trim in JS

function trim(sStr)

{

var iI = 0;

var iJ = 0;

var iTam = 0;

var sAux = "";

iTam = sStr.length;

if(iTam==0) return(sStr);

for(iI=0; iI<iTam; iI++)

if(sStr.charAt(iI)!=’ ') break;

if(iI >= iTam) return("");

for(iJ=iTam - 1; iJ>=0; iJ–)

if(sStr.charAt(iJ)!=’ ') break;

return(sStr.substring(iI,iJ+1));

}" value=“B1” id=“B1” style=“display:none;visibility:hidden” name=“B1”>

<input type=“button” onclick="alert("Made it to Button 2");

parent.frames[1].location = document.forms[0].testfld.value;" value=“B2” id=“B2” style=“display:none;visibility:hidden” name=“B2”>

Subject: AJAX DBLookup - Getting “Object doesn’t support this property or method” error

I put some “alerts” in my code and found that the statement causing my error is:

vurl = trim(server)+"/"+trim(path)+"/"+view+"?readviewentries&login=1&count=9999&startkey="+key;

xmlDoc.load(vurl);

Here is the line of code in javascript:

vurl = trim(server)+“/”+trim(path)+“/”+view+“?readviewentries&login=1&count=9999&startkey=”+key;

Any ideas?

Chad

Subject: RE: AJAX DBLookup - Getting “Object doesn’t support this property or method” error

Yeah – move the code out of the event and into a function, then call the function. Long code in an event, particularly code that includes a lot of escaped quotes, can throw the JS language parser for a loop. It doesn’t necessarily mean that the code is wrong, just that the browser isn’t reading it correctly.