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