程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ztree-頁面中多個input select,想要每個inpu中顯示不同內容,該怎麼做?

ztree-頁面中多個input select,想要每個inpu中顯示不同內容,該怎麼做?

編輯:編程綜合問答
頁面中多個input select,想要每個inpu中顯示不同內容,該怎麼做?

使用Jquery Ztree 頁面中多個input select,想要每個inpu中顯示不同內容,該怎麼做?

 <!DOCTYPE html>
<HTML>
<HEAD>
    <TITLE> ZTREE DEMO - radio select menu</TITLE>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="../../../css/demo.css" type="text/css">
    <link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="../../../js/jquery.ztree.core-3.5.js"></script>
    <script type="text/javascript" src="../../../js/jquery.ztree.excheck-3.5.js"></script>
<!--    <script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script>-->
    <SCRIPT type="text/javascript">
        <!--
        var setting = {
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            view: {
                dblClickExpand: false
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                onClick: onClick,
                onCheck: onCheck
            }
        };

        var zNodes =[
            {id:1, pId:0, name:"北京"},
            {id:2, pId:0, name:"天津"},
            {id:3, pId:0, name:"上海"},
            {id:6, pId:0, name:"重慶"}
         ];
         var zNodes1 =[
            {id:4, pId:0, name:"河北省", open:true, nocheck:true},
            {id:41, pId:4, name:"石家莊"},
            {id:42, pId:4, name:"保定"},
            {id:43, pId:4, name:"邯鄲"},
            {id:44, pId:4, name:"承德"}
         ];

        function onClick(e, treeId, treeNode) {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            zTree.checkNode(treeNode, !treeNode.checked, null, true);
            return false;
        }


        function hideMenu() {
            $("#menuContent").fadeOut("fast");
            $("body").unbind("mousedown", onBodyDown);
        }
        function onBodyDown(event) {
            if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
                hideMenu();
            }
        }

        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            $.fn.zTree.init($("#treeDemo1"), setting, zNodes1);
        });


         function onCheck(e, treeId, treeNode) {
            var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            nodes = zTree.getCheckedNodes(true),
            v = "";
            for (var i=0, l=nodes.length; i<l; i++) {
                v += nodes[i].name + ",";
            }
            if (v.length > 0 ) v = v.substring(0, v.length-1);
            //var cityObj = $("#citySel");
            currentObj.attr("value", v);////////使用變量存儲的input對象
        }
        var currentObj;////////////存儲當前操作的input對象
        function showMenu(o) {
            var cityObj = $(o);
            if (o.tagName == 'A') cityObj = cityObj.parent().find('input');//點擊的是連接,獲取和連接對應的input對象
            currentObj=cityObj///
            var cityOffset = cityObj.offset();
            $("#menuContent").css({ left: cityOffset.left + "px", top: cityOffset.top + cityObj.outerHeight() + "px" }).slideDown("fast");

            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = treeObj.getSelectedNodes();
            if (nodes.length > 0) treeObj.checkNode(nodes[0], false, null, false);//取消ztree的選擇

            $("body").bind("mousedown", onBodyDown);
        }
        //-->
    </SCRIPT>
    <style type="text/css">
    </style>
 </HEAD>

<BODY>
<h1>帶 radio 的單選下拉菜單  -- zTree</h1>
<h6>[ 文件路徑: super/select_menu_radio.html ]</h6>
<div class="content_wrap">
    <div class="zTreeDemoBackground left">
           <ul class="list">
                <li class="title">&nbsp;&nbsp;<span class="highlight_red">勾選 radio 或者 點擊節點 進行選擇</span></li>
                <li class="title">
                    &nbsp;&nbsp;Test: <input id="citySel" type="text" readonly value="" style="width:120px;" onclick="showMenu(this);" />
                    &nbsp;<a id="menuBtn" href="#" onclick="showMenu(this); return false;">select</a>
                </li>
                <li class="title">
                    &nbsp;&nbsp;Test: <input id="citySel" type="text" readonly value="" style="width:120px;" onclick="showMenu(this);" />
                    &nbsp;<a id="menuBtn" href="#" onclick="showMenu(this); return false;">select</a>
                </li>
                <li class="title">
                    &nbsp;&nbsp;Test: <input id="citySel" type="text" readonly value="" style="width:120px;" onclick="showMenu(this);" />
                    &nbsp;<a id="menuBtn" href="#" onclick="showMenu(this); return false;">select</a>
                </li>
            </ul>
    </div>
    <div class="right">
        <ul class="info">
            <li class="title"><h2>實現方法說明</h2>
                <ul class="list">
                <li>用 radio 也可以輕松實現單選的下拉菜單</li>
                <li>單選其實沒有必要使用 radio, 此 Demo 主要用於 和 其他下拉菜單進行對比</li>
                </ul>
            </li>
        </ul>
    </div>
</div>

<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
    <ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
</div>
<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
    <ul id="treeDemo1" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
</div>
</BODY>
</HTML>

最佳回答:


這裡不是回復過了,你到底要先干嘛?http://ask.csdn.net/questions/194775

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved