Advertisement
val10

Untitled

Sep 18th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.91 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>GetJson</title>
  5. <script type="text/javascript">
  6. jSon=[{
  7.     "name": "Planning",
  8.     "id": 1,
  9.  "parentId": 994423,
  10.     "children": [{
  11.   "name": "Investigate",
  12.   "id": 11,
  13.   "parentId": 1
  14.  }, {
  15.   "name": "Assign resources",
  16.   "id": 12,
  17.   "parentId": 1
  18.  }, {
  19.   "name": "Gather documents",
  20.   "id": 13,
  21.   "parentId": 1
  22.  }, {
  23.   "name": "Report to management",
  24.   "id": 17,
  25.   "parentId": 1,
  26.   "children": [{
  27.    "name": "Implementation Phase 1",
  28.    "id": 4,
  29.    "parentId": 17,
  30.    "children": [{
  31.     "name": "Preparation work",
  32.     "id": 34,
  33.     "parentId": 4
  34.    }, {
  35.     "name": "Evaluate chipsets",
  36.     "id": 14,
  37.     "parentId": 4
  38.    }, {
  39.     "name": "Choose technology suite",
  40.     "id": 16,
  41.     "parentId": 4
  42.    }, {
  43.     "name": "Build prototype",
  44.     "id": 15,
  45.     "parentId": 4,
  46.     "children": [{
  47.      "name": "Step 1",
  48.      "id": 20,
  49.      "parentId": 15
  50.     }, {
  51.      "name": "Step 2",
  52.      "id": 19,
  53.      "parentId": 15
  54.     }, {
  55.      "name": "Step 3",
  56.      "id": 18,
  57.      "parentId": 15
  58.     }, {
  59.      "name": "Follow up with customer",
  60.      "id": 21,
  61.      "parentId": 15,
  62.      "children": [{
  63.       "name": "Customer approval",
  64.       "id": 5,
  65.       "parentId": 21
  66.      }, {
  67.       "name": "Implementation Phase 2",
  68.       "id": 6,
  69.       "parentId": 21,
  70.       "children": [{
  71.        "name": "Task 3",
  72.        "id": 25,
  73.        "parentId": 6
  74.       }, {
  75.        "name": "Task 2",
  76.        "id": 26,
  77.        "parentId": 6
  78.       }, {
  79.        "name": "Task 1",
  80.        "id": 27,
  81.        "parentId": 6,
  82.        "children": [{
  83.         "name": "Production phase 1",
  84.         "id": 8,
  85.         "parentId": 27,
  86.         "children": [{
  87.          "name": "Assemble",
  88.          "id": 22,
  89.          "parentId": 8
  90.         }, {
  91.          "name": "Load SW",
  92.          "id": 23,
  93.          "parentId": 8
  94.         }, {
  95.          "name": "Basic testing (inc some test)",
  96.          "id": 24,
  97.          "parentId": 8,
  98.          "children": [{
  99.           "name": "Customer approval 2",
  100.           "id": 10,
  101.           "parentId": 24
  102.          }]
  103.         }]
  104.        }]
  105.       }]
  106.      }]
  107.     }]
  108.    }]
  109.   }]
  110.  }]
  111. }, {
  112.     "name": "Final testing",
  113.     "id": 9,
  114.     "parentId": 123321
  115. }, {
  116.     "name": "Delivery",
  117.     "id": 7,
  118.     "parentId": 654321
  119. }];
  120. </script>
  121. </head>
  122. <body>
  123. <div>
  124. <select id="selPath" onchange="dsplyPath.innerHTML=value"></select>
  125. <textarea id="dsplyPath" rows="5" cols="50"></textarea>
  126. </div>
  127. <script type="text/javascript">
  128. (function (obj,objName){
  129.  obj.names= "";
  130.  (function recurseIt(obj){
  131.       for(var a in obj){
  132.    if(typeof obj[a] == "object" ){  
  133.    obj[a].names= obj.names + (obj[a]["name"] ? "/" + obj[a]["name"]:"");
  134.     recurseIt(obj[a]);
  135.    }else{
  136.     if(a == "name")selPath.add(new Option(obj[a],obj["names"]))
  137.    }
  138.       }
  139.  })(obj);
  140. })(jSon);
  141. </script>
  142. </body>
  143. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement