xaero Posted July 23, 2007 Report Share Posted July 23, 2007 Na primer u menya est takoy massiv:var tree = ['Home', 'Products', 'JavaScript', ['Functions', 'Objects', 'Classes', ['DYNAPI', 'MyFrame', 'X-Objects' ], 'Variables' ], 'Current', 'Machines' ]Ya xotel bi ego otobrajat kak tree view pomogite napisat funksiyu...Ya sam poproboval no eto ogronicheno, function TM(a){ for(i=0; i { if(typeof a=='object') { for(ii=0; ii { if(typeof a[ii]=='object') { for(iii=0; iii Link to comment Share on other sites More sharing options...
0 AKS Posted July 23, 2007 Report Share Posted July 23, 2007 Как-нибудь так, наверно:var tree = ['Home', 'Products', 'JavaScript', ['Functions', 'Objects', 'Classes', ['DYNAPI', 'MyFrame', 'X-Objects' ], 'Variables' ], 'Current', 'Machines' ];function F(t) { var html = '<ul>', item; for (var i = 0, len = t.length; i < len; i++) { item = t[i]; if (typeof item == 'string') { html += '<li>' + item + '</li>'; } else if (item instanceof Array) { html = html.substring(0, html.lastIndexOf('</li>')); html += F(item); } } html += '</ul>'; return html;}onload = function () { document.body.innerHTML += F(tree);} Link to comment Share on other sites More sharing options...
Question
xaero
Na primer u menya est takoy massiv:
var tree = ['Home',
'Products',
'JavaScript',
['Functions',
'Objects',
'Classes',
['DYNAPI',
'MyFrame',
'X-Objects'
],
'Variables'
],
'Current',
'Machines'
]
Ya xotel bi ego otobrajat kak tree view pomogite napisat funksiyu...
Ya sam poproboval no eto ogronicheno,
function TM(a)
{
for(i=0; i
{
if(typeof a=='object')
{
for(ii=0; ii
{
if(typeof a[ii]=='object')
{
for(iii=0; iii
Link to comment
Share on other sites
1 answer to this question
Recommended Posts