8 Years
Discussion Span
Last Post by closetosane

Here is a link for a very simple tree view: http://www.htmlforums.com/html-xhtml/t-how-do-i-make-an-expandable-list-43732.html

It can be modified to allow for multiple tree views as shown in this example.

<script type="text/javascript">
  function toggleBox(id){
    if (document.getElementById(id).style.display = = "") {
       show = "none";
  } else {
       show = "";
    document.getElementById(id).style.display = show;
<table width="100%" align="center">
      <td><a href="javascript:toggleBox(1)">+</a>&nbsp;<a href="" >Drive Letter</a></td>
<table width="100%" border="0" align="center" id="1" style="display: none;">
      <td bgcolor="#FFFFFF" width="30">&nbsp;</td>
      <td bgcolor="#FFFFFF" width="*">
      &nbsp;<a href="javascript:toggleBox(2)">+</a>&nbsp;<a href="" >Folder</a></td>
<table width="100%" border="0" align="center" id="2" style="display: none;">
      <td bgcolor="#FFFFFF" width="70">&nbsp;</td>
      <td bgcolor="#FFFFFF" width="*">&nbsp;
      <a href="../drive.asp?operator=Delete&file=C:\folder\filename.txt">File</a></td>

So now with an easy to use tree the next thing you might want to do is use images instead or with the names in the tree as follows:

%><td width="10"><a href="javascript:toggleBox(<%= intCount1 %>)">
           <img border="0" src="../Graphics/Folder.gif"></a><a href="" ></a></td><%

Also note that a variable “intCount1” is used instead of hard coding the javascript:toggleBox value, a variable can also be used with the ID to make this code very dynamic with some loops.

Now for the deleting file: A static tree makes no sense as you will need to change the code each time a file is deleted. For a dynamic list you will need to search the drive and write the file names into variables in the anchors. Start your tree with the root C:\ (or whatever your root/folder that you want to start is) Then search for folder names and files inside the folders as you loop through this write the values into the anchors. Example:

<a href="../drive.asp?operator=Delete&file=<%= Path1 %>

Path1 will be the path to the file example: (C:\folder\filename.txt).

So now that the tree is created when you click on the text or graphic corresponding to the path you will be directed to the html link with a querystring containing two values. The first value (in this case operator) will give a conditional statement, the second (File) will point to the path of the file you wish to delete.

If operator = Delete Then
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
End if

With C:\folder\filename.txt being the value contained in Path1

My assumption being that you are asking about asp pages is that you will be using vbscript and are on a windows server.

For some more information on FileSystemObjects check out the following links


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.