dbLookUp : xmlDoc.documentElement problem

Hi,

Below is the dbLookup function that is present in the JSHeader of my form and is being called on the OnChange event of a dropdown to populate other dropdowns.

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

xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);

xmlDoc.async = true;

var pos=0;

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

if (trim(server) == “”) {

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

if (pos < 0 )

server = “http://11.22.33.44” // 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)+“:81/”+trim(path)+“/”+view+“?ReadViewEntries&login=1&count=100&startkey=”+key;

xmlDoc.async=“false”;

xmlDoc.onreadystatechange=verify;

xmlDoc.load(vurl);

alert (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++)

{

alert (nodes.item(i).childNodes.item(0).text);

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

{

alert (temp[i]);

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

}

}

return(results);

} //End of dbLookup

function verify()

{

if (xmlDoc.readyState != 4)

{

return false;

}

}

The function returns null value in the following lines in the above code:

if (xmlDoc.documentElement == undefined)

{

return(“”)

}

the value of ‘vurl’ is correct and I copy pasted it in the IE and it shows the correct value in the view. Can anyone please let me know why xmlDoc.documentElement is coming undefined?? Is there any setting that needs to be done on the form or in the view?? please help!!!

Thanks in advance,

Vishesh

Subject: dbLookUp : xmlDoc.documentElement problem

You are trying to get the DocumentElement of the ActiveX object – you should be getting the DocumentElement of the responseXML it generates.

Subject: RE: dbLookUp : xmlDoc.documentElement problem

Hello Stan, Thanks for your response. Actually I am new to AJAX n XML and I got this code from this forum itself. If I am not wrong the person who posted it was you. I really appreciate it!

Can you please let me know how to exactly get the documentElement of the responseXML. i.e. how responseXML is generated? Please!

Vishesh

Subject: dbLookUp : xmlDoc.documentElement problem

http://www-10.lotus.com/ldd/nd6forum.nsf/0/ce4d78eb5ef91517852574750060b795?OpenDocument