Two images are needed for each folder. The first image will create a subfolder when clicked, while the second image will delete the folder along with all its subfolders.
I have written some code that can create subfolders but cannot delete them. As a beginner in Javascript, I would appreciate any help
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Javascript Directory code</title>
<style>
ul
{
list-style-image:url('closed.gif');
}
</style>
</head>
<body>
<ul>
<li onClick="myFunction.call(this, event)" id="root">Root</li>
</ul>
<script language="javascript" type="text/javascript">
function myFunction(e)
{
e.stopPropagation();
var id=prompt("Enter Folder id");
if (id != '' && id != null)
{
var val=prompt("Enter Folder name");
}
if (id != '' && id != null && val !='' && val !=null)
{
var ulnode=document.createElement("UL"); //new ul<br>
var node=document.createElement("LI"); //new li<br>
node.id = id;//set id of new li <br>
node.onclick = myFunction;//set onclick event of new li<br>
var textnode=document.createTextNode(val);//li value<br>
node.appendChild(textnode);// new li + li value<br>
ulnode.appendChild(node);// ul + li value
this.appendChild(ulnode);
}
}
</script>
</body>
</html>