会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
boytomato
js 树的几个小技巧
function
s()
{
var
clickedNodeIndex
=
left_TreeView1.clickedNodeIndex;
var
nodeArray
=
new
Array();
var
i
=
clickedNodeIndex.lastIndexOf('.');
var
pIndex;
if
(i
==-
1
){
nodeArray
=
left_TreeView1.getChildren();
}
else
{
pIndex
=
clickedNodeIndex.substring(
0
,i);
var
pNode
=
left_TreeView1.getTreeNode(pIndex);
nodeArray
=
pNode.getChildren();
}
for
(i
=
0
;i
<
nodeArray.length;i
++
)
{
var
index;
if
(pIndex
==
null
)
{index
=
i
+
'';
}
else
{index
=
pIndex
+
';'
+
i;}
var
cNode;
cNode
=
nodeArray[i];
if
(index
!=
clickedNodeIndex)
{cNode.setAttribute('Expanded',
false
);}}}
function
GetNode()
{
var
choose;
var
indexid;
indexid
=
left_TreeView1.clickedNodeIndex;
if
(left_TreeView1.getTreeNode(indexid).getAttribute('Checked'))
{
choose
=
true
;
}
else
{
choose
=
false
;
}
var
Nodelist
=
new
Array();
Nodelist
=
left_TreeView1.getChildren();
for
(j
=
0
;j
<
Nodelist.length ;j
++
)
{
if
(indexid.charAt(
0
)
==
'
0
'
||
indexid.charAt(
0
)
==
'
2
'
||
indexid.charAt(
0
)
==
'
3
'
||
indexid.charAt(
0
)
==
'
1
')
{
if
(j
!=
indexid.charAt(
0
))
{
var
temp
=
j
+
'';
left_TreeView1.getTreeNode(temp).setAttribute('Checked',
false
);
var
no
=
new
Array();
no
=
left_TreeView1.getTreeNode(temp).getChildren();
for
(k
=
0
;k
<
no.length ;k
++
)
{
var
temp1
=
temp
+
'.'
+
k;
left_TreeView1.getTreeNode(temp1).setAttribute('Checked',
false
);
}
}
}
}
if
(choose
==
true
)
{
}
else
{
}
var
child
=
indexid.charAt(
0
);
var
temp3
=
new
Array();
temp3
=
left_TreeView1.getTreeNode(child).getChildren();
document.all.left_TextBox1.value
=
'';
var
flag_select
=
0
;
for
(l
=
0
;l
<
temp3.length ;l
++
)
{
var
temp4
=
child
+
'.'
+
l;
if
( left_TreeView1.getTreeNode(temp4).getAttribute('Checked')
==
true
)
{
document.all.left_TextBox1.value
=
document.all.left_TextBox1.value
+
left_TreeView1.getTreeNode(temp4).getAttribute('NodeData')
+
'
|
';
flag_select
=
flag_select
+
1
;
}
if
(flag_select
>
0
)
{ document.all.left_TextBox2.value
=
indexid.charAt(
0
);
}
else
{
document.all.left_TextBox2.value
=
'';
}
}
var
NodeArray
=
new
Array();
NodeArray
=
left_TreeView1.getTreeNode(indexid).getChildren();
for
(i
=
0
;i
<
NodeArray.length;i
++
)
{
var
tempindex
=
indexid
+
'.'
+
i;
left_TreeView1.getTreeNode(tempindex).setAttribute('Checked',choose);
if
(choose
==
true
)
{
document.all.left_TextBox1.value
=
'
0
';
document.all.left_TextBox2.value
=
indexid;
}
else
{
document.all.left_TextBox1.value
=
'';;
document.all.left_TextBox2.value
=
'';;
}
}
}
posted on
2005-03-13 19:57
gwazy
阅读(
1282
) 评论(
1
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
新随笔
联系
订阅
管理
公告