function InitializeTreeView() { var TreeView = document.getElementById('TreeView') var categoryjoined; var categoryIDAndName; var checkbox; var cell; var celltext; var counter = 0; var div; var image; var memberinformationlist; var memberinformationparsedlist; var row; var subcategoryID; var table = document.createElement("table"); var tablebody = document.createElement("tbody"); var textfield; var returnedData = Ajax.categorymanagement.InitializeMemberMainCategories(); memberinformationlist = String(returnedData.value).split(";") for(counter = 0; counter <= memberinformationlist.length - 2; counter++) { memberinformationparsedlist = String(memberinformationlist[counter]).split("|") //memberinformationparsedlist[0] = CategoryID //memberinformationparsedlist[1] = SubCategoryID //memberinformationparsedlist[2] = CategoryJoined //memberinformationparsedlist[3] = CategoryName //Get the category name. celltext = document.createTextNode(String(memberinformationparsedlist[3])); div = document.createElement("div"); div.setAttribute( "id", "CategoryNode-" + String(memberinformationparsedlist[0])); div.Style = "display: block; className: WhiteMessageLabel"; //div.style.className = "WhiteMessageLabel"; //If the subcategory is 0, then this means there are no subcategories in the system. //Therefore the user can only select the main category. //Also, there will be no "expaned" image for this category. if(Number(memberinformationparsedlist[1]) == 0) { //If the member has already joined this category, //then we must display a checkbox with the catgory being checked. checkbox = document.createElement("input"); checkbox.setAttribute( "id", "chkMainCategory-" + memberinformationparsedlist[0]); checkbox.setAttribute( "type", "checkbox" ); if(Number(memberinformationparsedlist[2]) > 0) { checkbox.setAttribute( "value", "checked" ); } //Now add the checkbox next to the category name. div.appendChild(checkbox); div.appendChild(celltext); } else { image = document.createElement("img"); image.setAttribute( "id", "imgCategory-" + memberinformationparsedlist[0]); image.setAttribute( "src", "images/notexpanded.gif" ); image.onclick = new Function("RetrieveSubCategories1('" + memberinformationparsedlist[2] + "');"); textfield = document.createElement("input"); textfield.setAttribute( "id", "imgCategoryMainHidden-" + memberinformationparsedlist[0]) textfield.setAttribute( "type", "hidden") textfield.setAttribute( "value", "notexpanded.gif") //Now add the expaned image, category name, and hidden image text field to the div tag. div.appendChild(image); div.appendChild(celltext); div.appendChild(textfield); } cell = document.createElement("td"); cell.appendChild(div); row = document.createElement("tr"); row.appendChild(cell); tablebody.appendChild(row); } table.appendChild(tablebody); alert(table.innerHTML); TreeView.appendChild(table); }