Hi, I have a tree menu that expands and collapse with the default XHTML bullets
I would like to add couple of lines to the existing javascript functions that i have to change the those bullets to the Windows Standard Plus and Minus images, which i have them in files called: plus.gif and minus.gif
My tree-men is pulled dynamically from a database but to demonstrate i'll just put a static list to make it easy, i dont think it would make a difference once i know how to change the bullets to image on expand/collapse
I appreciate your help very much.
here is the simple code
<STYLE TYPE='text/css'>
li.Item {
color: #0000FF;
cursor: hand;
display: table-row;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 20px;
} ;
li.Main {
color: #0000FF;
cursor: hand;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 20px;
} ;
ul ul { display: none; } ;
</STYLE>
<SCRIPT LANGUAGE='Javascript'>
function checkParent( src, tagName ) {
while ( src != null ) {
if (src.tagName == tagName)
return src;
src = src.parentElement;
}
return null;
}
function checkContent( src, tagName ) {
var pos = src.sourceIndex ;
while ( src.contains( document.all[++pos] ) )
if ( document.all[pos].tagName == tagName )
return document.all[pos] ;
return null ;
}
// onClick event
function outlineAction() {
var src = event.srcElement ;
var item = checkParent( src, "LI" ) ;
if ( parent != null ) {
var content = checkContent( item, "UL" ) ;
if ( content != null )
if ( content.style.display == "" )
content.style.display = "block" ;
else
content.style.display = "" ;
}
event.cancelBubble = true;
}
</SCRIPT>
<body>
<DIV onClick="JavaScript: outlineAction();">
<UL>
<LI class='Main'>List1
<UL>
<LI class='Item'>Item1</LI>
<LI class='Item'>Item2</LI>
<LI class='Item'>Item3</LI>
</UL>
</LI>
<LI class='Main'> List2
<UL>
<LI class='Item'>Item1</LI>
<LI class='Item'>Item2</LI>
<LI class='Item'>Item3</LI>
</UL>
</LI>
<LI class='Main'> List3
<UL>
<LI class='Item'>Item1</LI>
<LI class='Item'>Item2</LI>
<LI class='Item'>Item3</LI>
</UL>
</LI>
</UL>
</DIV>
</body>
I would like to add couple of lines to the existing javascript functions that i have to change the those bullets to the Windows Standard Plus and Minus images, which i have them in files called: plus.gif and minus.gif
My tree-men is pulled dynamically from a database but to demonstrate i'll just put a static list to make it easy, i dont think it would make a difference once i know how to change the bullets to image on expand/collapse
I appreciate your help very much.
here is the simple code
<STYLE TYPE='text/css'>
li.Item {
color: #0000FF;
cursor: hand;
display: table-row;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 20px;
} ;
li.Main {
color: #0000FF;
cursor: hand;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 20px;
} ;
ul ul { display: none; } ;
</STYLE>
<SCRIPT LANGUAGE='Javascript'>
function checkParent( src, tagName ) {
while ( src != null ) {
if (src.tagName == tagName)
return src;
src = src.parentElement;
}
return null;
}
function checkContent( src, tagName ) {
var pos = src.sourceIndex ;
while ( src.contains( document.all[++pos] ) )
if ( document.all[pos].tagName == tagName )
return document.all[pos] ;
return null ;
}
// onClick event
function outlineAction() {
var src = event.srcElement ;
var item = checkParent( src, "LI" ) ;
if ( parent != null ) {
var content = checkContent( item, "UL" ) ;
if ( content != null )
if ( content.style.display == "" )
content.style.display = "block" ;
else
content.style.display = "" ;
}
event.cancelBubble = true;
}
</SCRIPT>
<body>
<DIV onClick="JavaScript: outlineAction();">
<UL>
<LI class='Main'>List1
<UL>
<LI class='Item'>Item1</LI>
<LI class='Item'>Item2</LI>
<LI class='Item'>Item3</LI>
</UL>
</LI>
<LI class='Main'> List2
<UL>
<LI class='Item'>Item1</LI>
<LI class='Item'>Item2</LI>
<LI class='Item'>Item3</LI>
</UL>
</LI>
<LI class='Main'> List3
<UL>
<LI class='Item'>Item1</LI>
<LI class='Item'>Item2</LI>
<LI class='Item'>Item3</LI>
</UL>
</LI>
</UL>
</DIV>
</body>