Troubleshooting the Simple Ajax Treeview

Hi experts,

I downloaded some sample code to create a treeview using ajax and sql but I'm having difficulties getting it to work with my tables. I'm getting the error of a blank page. I downloaded the sample code from
I ran the query in the analyzer and it produced good results when i swapped out my userID for intParentId. I can't figure for the life of me where the origional parentId (mentorID) comes from in this script. Please look at the code to help me figure out what I'm doing wrong. Thanks!
Class TreeView
Private m_strMenuTable
Private m_strIdField
Private m_strParentIDField
Private m_strTextField
Private m_strConn
Public Property Let MenuTable(vNewValue): m_strMenuTable = vNewValue: End Property
Public Property Let IdField(vNewValue): m_strIdField = vNewValue: End Property
Public Property Let ParentIDField(vNewValue): m_strParentIdField = vNewValue: End Property
Public Property Let TextField(vNewValue): m_strTextField = vNewValue: End Property
Public Property Let ConnectionString(vNewValue): m_strConn = vNewValue: End Property
Private Sub Class_Initialize
	m_strMenuTable = "dbo.Members"
	m_strIdField = "userID"
	m_strParentIDField = "mentorID"
	m_strTextField = "lastName" & "," & "firstName"
End Sub
Private Sub Class_Terminate
	'Clear Objects 
End Sub
Public Function GetChildNodes(intParentId)
	Dim strSQL
	strSQL = "SELECT " & _
	m_strIdField & "," & _
	m_strTextField & "," & _
	"(SELECT COUNT(*) FROM " & m_strMenuTable & " B WHERE A."& m_strIdField &"=B." & m_strParentIDField & ") AS [HasChild]" & _
	" FROM " & m_strMenuTable &" A "& _
	" WHERE " & m_strParentIDField & " = " & intParentId
	Const strXsl = "treeview.xsl"
	GetChildNodes = GetDbXml(m_strConn,strSQL, strXsl)
End Function
Private Function GetDbXml(strConn,strSQL,strXsl)
	Dim strXml
	'test strsql
	strXml = GetDbString(strConn,strSql,"__COL","__ROW","__NULL")
	strXml = Replace(strXml,"&","&amp;")
	strXml = Replace(strXml,"<","&lt;")
	strXml = Replace(strXml,"__COL","</col><col>")
	strXml = Replace(strXml,"__ROW","</col></row><row><col>")
	strXml = Replace(strXml,"__NULL","")	
	strXml = "<rows><row><col>" & strXml & "</col></row></rows>"			
	strXml = Replace(strXml,"<row><col></col></row>","")
	If strXsl <> "" Then		
		Dim xml,xsl
		'Load XML
		if not loadXmlDoc(xml,strXml,"GetDb XML Source") then exit Function
		if not loadXmlDoc(xsl,strXsl,"GetDb XSL Stylesheet") then exit Function
		'Transform file
		strXml = xml.transformNode(xsl)
		Set xml = Nothing
		Set xsl = Nothing
	End If
	GetDbXml = strXml        	
End Function 
Private Function GetDbString(strConn,strSQL, ColumnDelimiter, RowDelimiter, NullExpr)
	Dim Conn 
	Set Conn = Server.CreateObject("ADODB.Connection")
	Conn.Open strConn
	Dim RS
	Set RS = Conn.Execute(strSql)		
	If Not RS.EOF Then		
		GetDbString = RS.GetString(,, ColumnDelimiter, RowDelimiter, NullExpr) 
	End If	
	Set RS = Nothing
	Set Conn = Nothing					
End function
Private Function LoadXmlDoc(ByRef xmldoc, ByVal source, ByVal title)
	If Trim(source) = "" Then
		Exit Function
	End If
	Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
	If Left(source,7) = "http://" Then
		xmldoc.setProperty "ServerHTTPRequest", True
		xmldoc.async =  False
		'set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
		xmldoc.async = false
		If InStr(source,"<") Then 
			if InStr(source,":\") = 0 then source = Server.MapPath(source)
			'test source
		end if
	End If
	if xmldoc.parseError.errorcode <> 0 then
		'"<error code='" & xmldoc.parseError.errorcode & "'><![CDATA[" & xmldoc.parseError.reason & "]]></error>"
		LoadXmlDoc = True
	end if		
End Function
End Class
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
	<xsl:output method="xml" indent="no" omit-xml-declaration="yes" />
	<xsl:variable name="images.folder" select="'images'" />	
	<xsl:template match="/">		
			<xsl:apply-templates  />
	<xsl:template match="row">
		<xsl:variable name="" select="col[1]" />
		<xsl:variable name="text" select="col[2]" />
		<xsl:variable name="has.child" select="col[3]" />
		<table border="0" cellpadding="0" cellspacing="0">
				<td rowspan="2" width="10" valign="top">
					<img id="I{$}">
							<xsl:when test="number($has.child) &gt; 0">
								<xsl:attribute name="src">
									<xsl:value-of select="concat($images.folder,'/plus.gif')"/>
								<xsl:attribute name="onclick">
									<xsl:value-of select="concat('loadItems(',$,')')"/>
								<xsl:attribute name="src">
									<xsl:value-of select="concat($images.folder,'/dot.gif')"/>
				<td nowrap="true">
					<a href="javascript:alert({$});">
						<xsl:value-of select="$text" />						
				<td id="C{$}" style="display:none;"></td>
// global request and XML document objects
var req;
// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadXMLDoc(url) {	
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;"GET", url, true);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        //isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
  "GET", url, true);
// handle onreadystatechange event of req object
function processReqChange(){
	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {		
			// ...processing statements go here...
			response  = req.responseXML.documentElement;
			method =
			//result = response.getElementsByTagName('result')[0];
			var start = req.responseText.indexOf('<result>') + 8
			var stop = req.responseText.indexOf('</result>')
			result = req.responseText.substring(start,stop);
			eval(method + '(\'\', result)');
		} else {
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
var current_el = null;
var loading;
var began = false      
function getItems(input, response){	
	if (response != ''){ 		
	    // Response mode	
        current_el.innerHTML = response; = 'none'
		// Input mode			
		var url  = "process_request.asp?p=" + input + "&hash=" + Math.random();
function loadItems(id,c){ 
	var img = null;
		c = "C" + id;
		img = document.getElementById("I"+id);
	current_el = document.getElementById(c);
	if( == 'none'){ = ''
		if(img)img.src = "images/minus.gif";
	}else{ = 'none'
		if(img)img.src = "images/plus.gif";
	if(current_el.innerHTML == ''){ = ''
function buildTree(id){
	if (!began){
		loading = document.getElementById("Loading")
		document.getElementById(id).style.display = 'none';
		began = true;
<%Option Explicit%>
<!--#include file="treeview.asp"-->
Sub GetItems(parentId)
	Dim strConn,strTable
	strTable = "dbo.Members"
	strConn = "Provider=sqloledb; Data; Initial Catalog=xxx; User ID=xxx; Password=xxx"
	Dim tv
	Set tv = New TreeView
	tv.MenuTable = strTable
	tv.ConnectionString = strConn
	Response.Write tv.GetChildNodes(MM_userID)
	Set tv = Nothing
End Sub
Dim parentId:parentId = Request("p") 
If parentId="" Then parentId = 0
Response.ContentType = "text/xml"
<%= "<?xml version='1.0' encoding='ISO-8859-1'  standalone='yes'?>" %>
  <result><% Call GetItems(parentId) %></result>

Open in new window

Who is Participating?
BadotzConnect With a Mentor Commented:
This is not a question, it is an expression of need for application development, and for those kinds of needs you should hire a developer.

We are not paid to do development here at EE -- we are just volunteers who answer questions for points and the occasional T-shirt.

Perhaps Rent-A-Coder or a similar service can help you.

Best of luck with your project.
GMMC_manAuthor Commented:
Ok - thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.