79 messaggi dal 06 aprile 2004
Vi posto il codice JavaScript:
---------------------------------------------------------------------
<%
Dim first_rs
Dim first_rs_numRows
Dim itemCount, itemOrder

Set first_rs = Server.CreateObject("ADODB.Recordset")

strConn = "Provider=sqloledb; Data Source=PC-DELL2001\SQLEXPRESS; Initial Catalog=shelight_com_db; User Id=sa; Password=300479;"
first_rs.ActiveConnection = strConn
'Finding top level(root) objects
first_rs.Source = "SELECT * FROM vistaCategorie WHERE lang='"+lang+"' AND ParentId = 0;"
first_rs.CursorType = 0
first_rs.CursorLocation = 2
first_rs.LockType = 1
first_rs.Open()
first_rs_numRows = 0
%>
<html>
<style>
a:link, a:active, a:hover, a:visited {
text-decoration: none;
color: #000000;
font-size: 11 px;
font-variant: normal;
font-weight: bold;
font-family: Arial;
font-style: normal;
}
tree{background:#000;}
</style>

<body link="#666666" vlink="#666666" alink="#666666">
<XML id="dsoELEMANLAR"></XML>
<script language="Javascript">
function redirect(URLStr) { location = URLStr; }
function expand(par,iorder,icount) {
var currNode;
var imgop_node='fopen.gif';
var imgcl_node='fclose.gif';
dsoELEMANLAR.async = false;
//executing tree_process.asp with strID when an item clicked
dsoELEMANLAR.SRC="tree_process.asp?strID=" + par
objNodeListMenuId = dsoELEMANLAR.getElementsByTagName("MenuId");
objNodeListMenuName = dsoELEMANLAR.getElementsByTagName("MenuName");
objNodeListMenuLink = dsoELEMANLAR.getElementsByTagName("MenuLink");
objNodeListMenuTarget = dsoELEMANLAR.getElementsByTagName("MenuTarget");
objNodeListcounter = dsoELEMANLAR.getElementsByTagName("counter");
objNodeListitemcount = dsoELEMANLAR.getElementsByTagName("itemcount");
objNodeListitemorder = dsoELEMANLAR.getElementsByTagName("itemorder");
str='navLink'+par;
str2='picker'+par;
if (document.all(str).style.display=='none') {

if (objNodeListMenuId.length>0){
document.all(str).style.display="";
document.all(str2).src=imgop_node;
for (var i=0; i < objNodeListMenuId.length; i++) {
// writing space and spacer image about the amount of the distance from top level object
for (var j=0; j <(objNodeListcounter.item(i).text-1); j++)
{
if(j<objNodeListcounter.item(i).text-2)
{
document.all(str).innerHTML+='<img src="icon_vbar.gif" width="15" height="15" border="0" alt="">';
}
else
{
if ((iorder!=icount)) document.all(str).innerHTML+='<img src="icon_vbar.gif" width="15" height="15" border="0" alt="">';
else document.all(str).innerHTML+='<img src="icon_blank.gif" width="15" height="15" border="0" alt="">';
}

}

if ((i+1)==objNodeListMenuId.length) document.all(str).innerHTML+='aa<img src="icon_bar.gif" width="15" height="15" border="0" alt="">';
else document.all(str).innerHTML+='bb<img src="icon_tbar.gif" width="15" height="15" border="0" alt="">';

//writing bottom objects of the item clicked
document.all(str).innerHTML+='<a href="#" onClick="expand('+objNodeListMenuId.item(i).text+','+objNodeListitemorder.item(i).text+','+objNodeListitemcount.item(i).text+');"><img src="'+imgcl_node+'" name="picker'+objNodeListMenuId.item(i).text+'" border="0" align="middle"></a>';
document.all(str).innerHTML+=' <a href="#" onClick="expand('+objNodeListMenuId.item(i).text+','+objNodeListitemorder.item(i).text+','+objNodeListitemcount.item(i).text+');">'+objNodeListMenuName.item(i).text+'</a>';
//document.all(str).innerHTML+=' <a href="prodotti.asp?id_categoria='+objNodeListMenuId.item(i).text+'&lang=<%=lang%>">'+objNodeListMenuName.item(i).text+'</a>';
document.all(str).innerHTML+='<div id="navlink'+objNodeListMenuId.item(i).text+'" style="display=none;"></div>';
document.all(str).innerHTML+='<div style="font-size:1px;">&nbsp;</div>';
}
}
}
else
{
document.all(str).innerHTML='';
document.all(str).style.display="none";
document.all(str2).src=imgcl_node;
}
}
</script>
<%
ItemCount=0
ItemOrder=1
do while not first_rs.eof
ItemCount=ItemCount+1
first_rs.movenext
loop
first_rs.MoveFirst
'writing top level objects
do while not first_rs.eof
%>
<a href="#" onClick=expand(<%=(first_rs.Fields.Item("MenuId").Value)%>,<%=ItemOrder%>,<%=ItemCount%>)><img align="middle" src="fclose.gif" name="picker<%=(first_rs.Fields.Item("MenuId").Value)%>" border="0" align="absmiddle" ></a>
<a href="#" onClick=expand(<%=(first_rs.Fields.Item("MenuId").Value)%>,<%=ItemOrder%>,<%=ItemCount%>)><%=(first_rs.Fields.Item(2).Value)%></a>
<div id=navLink<%=(first_rs.Fields.Item(0).Value)%> style="display=none;"></div>

<div style="font-size:1px;">&nbsp;</div>
<%
ItemOrder=ItemOrder+1
first_rs.movenext
loop
%>
</body>
</html>
<%
first_rs.Close()
Set first_rs = Nothing
%>
---------------------------------------------------------------------

Questo script crea un menu ad albero con infinite gerarchie, proveniente da una tabella SqlServer.

La mia domanda è, come faccio ad ogni ultimo nodo impostargli un'icona diversa dal simbolo (+) e impostare un link diverso? Solo agli ultimi figli della gerarchia.

Per capire meglio trovate lo script originale al seguente indirizzo:

http://asp.html.it/script/vedi/3951/menu-ad-albero/

Grazie
Massimo

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.