当前位置: 代码迷 >> Web前端 >> zTree v3.1获取选中节点的值并赋给掩藏域
  详细解决方案

zTree v3.1获取选中节点的值并赋给掩藏域

热度:858   发布时间:2012-08-21 13:00:21.0
zTree v3.1获取选中节点的值并赋给隐藏域

function onCheck(e, treeId, treeNode) {
???var zTree = $.fn.zTree.getZTreeObj("testtree"),
???nodes = zTree.getCheckedNodes(true),
???v = "";
???for (var i=0, l=nodes.length; i<l; i++) {
????v += nodes[i].name + ",";
????alert(nodes[i].id);?? //获取选中节点的id值
????document.getElementById('test').value=nodes[i].id;
???}
???if (v.length > 0 ) v = v.substring(0, v.length-1);
???var cityObj = $("#citySel");
???cityObj.attr("value", v);
??}

?

?

<input type="hidden" name="test" id="test">

?

....

<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
?<ul id="testtree" class="ztree" style="margin-top:0; width:280px; height: 300px;"></ul>
</div>