Advertisement
Guest User

Cascading Dropdown

a guest
Jun 7th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fillCustomer(){
  2. /*------ Empty later dropdowns -----*/
  3. var arrTemp =[] /*---- empty array ----*/
  4.  
  5. {dialog.Object}.populateDropdownBox('SITE',arrTemp,true);
  6. {dialog.Object}.populateDropdownBox('SHOP',arrTemp,true);
  7. {dialog.Object}.populateDropdownBox('AREA_NAME',arrTemp,true);
  8.  
  9. /*------ Clear area_id ----------*/
  10. {dialog.Object}.setValue('AREA_ID','' )
  11.  
  12. var listData = {dialog.Object}.getListData('AREA_LOOKUP');
  13.  
  14. var i = null;
  15. for (i = 0; listData.length > i; i += 1) {
  16.     arrTemp.push(listData[i].customer);
  17. }
  18. var arrCust = arrTemp.filter(function (value, index, self) {
  19.     return self.indexOf(value) === index;
  20.   })
  21. /*----- Add select text ------*/
  22. arrCust.splice(0, 0, '<Select Customer>');
  23. {dialog.Object}.populateDropdownBox('CUSTOMER',arrCust,true);
  24. /*--- set to select text ----*/
  25. setTimeout(function(){{dialog.Object}.setValue('CUSTOMER','<Select Customer>',false )} ,10);
  26. }
  27.  
  28. function fillSite(){
  29. /*------ Empty later dropdowns -----*/
  30. var arrTemp =[] /*---- empty array ----*/
  31.  
  32. {dialog.Object}.populateDropdownBox('SHOP',arrTemp,true);
  33. {dialog.Object}.populateDropdownBox('AREA_NAME',arrTemp,true);
  34. /*------ Clear area_id ----------*/
  35. {dialog.Object}.setValue('AREA_ID','' )
  36.  
  37. /*------- Fill this dropdown if there is parent data ----*/
  38.  
  39. var customer = {dialog.Object}.getValue('CUSTOMER');
  40. if(customer!=''&&customer!='<Select Customer>'){
  41.     var listData = {dialog.Object}.getListData('AREA_LOOKUP');
  42.    
  43.     var i = null;
  44.     for (i = 0; listData.length > i; i += 1) {
  45.         if (listData[i].customer == customer){
  46.         arrTemp.push(listData[i].site);
  47.         }
  48.     }
  49.     var arrSite = arrTemp.filter(function (value, index, self) {
  50.         return self.indexOf(value) === index;
  51.       })
  52.        /*----- Add select text ------*/
  53.         arrSite.splice(0, 0, '<Select Site>');
  54.  
  55.     {dialog.Object}.populateDropdownBox('SITE',arrSite,true);
  56.     /*--- set to select text ----*/
  57.     setTimeout(function(){{dialog.Object}.setValue('SITE','<Select Site>',false )} ,10);
  58.  
  59.     } else {
  60.     {dialog.Object}.populateDropdownBox('SITE',arrTemp,true)
  61.     }
  62. }
  63. function fillShop(){
  64. /*------ Empty later dropdowns -----*/
  65. var arrTemp =[] /*---- empty array ----*/
  66. {dialog.Object}.populateDropdownBox('AREA_NAME',arrTemp,true);
  67. /*------ Clear area_id ----------*/
  68. {dialog.Object}.setValue('AREA_ID','' )
  69.  
  70. /*------- Fill this dropdown if there is parent data ----*/
  71. var customer = {dialog.Object}.getValue('CUSTOMER');
  72. var site = {dialog.Object}.getValue('SITE');
  73. if(customer!=''&&site!=''&&site!='<Select Site>'){
  74.     var listData = {dialog.Object}.getListData('AREA_LOOKUP');
  75.     var arrTemp =[]
  76.    
  77.     var i = null;
  78.     for (i = 0; listData.length > i; i += 1) {
  79.         if (listData[i].customer == customer&&listData[i].site==site){
  80.         arrTemp.push(listData[i].shop);
  81.         }
  82.     }
  83.     var arrShop = arrTemp.filter(function (value, index, self) {
  84.         return self.indexOf(value) === index;
  85.       })
  86.        /*----- Add select text ------*/
  87.         arrShop.splice(0, 0, '<Select Shop>');
  88.     {dialog.Object}.populateDropdownBox('SHOP',arrShop,true);
  89.     /*--- set to select text ----*/
  90.     setTimeout(function(){{dialog.Object}.setValue('SHOP','<Select Shop>',false )} ,10);
  91.  
  92.     } else {
  93.     {dialog.Object}.populateDropdownBox('SHOP',arrTemp,true);
  94.     }
  95. }
  96.  
  97. function fillArea(){
  98. /*------ Empty later dropdowns -----*/
  99. var arrTemp =[] /*---- empty array ----*/
  100. {dialog.Object}.populateDropdownBox('AREA_NAME',arrTemp,true);
  101. /*------ Clear area_id ----------*/
  102. {dialog.Object}.setValue('AREA_ID','' )
  103.  
  104. /*------- Fill this dropdown if there is parent data ----*/
  105. var customer = {dialog.Object}.getValue('CUSTOMER');
  106. var site = {dialog.Object}.getValue('SITE');
  107. var shop = {dialog.Object}.getValue('SHOP');
  108. if(customer!=''&&site!=''&&shop!=''&&shop!='<Select Shop>'){
  109.     var listData = {dialog.Object}.getListData('AREA_LOOKUP');
  110.     var arrTemp =[]
  111.    
  112.     var i = null;
  113.     for (i = 0; listData.length > i; i += 1) {
  114.         if (listData[i].customer == customer&&listData[i].site==site&&listData[i].shop==shop){
  115.         /*------ Local array for display name / stored name -------*/
  116.         arrV = [listData[i].area_name,listData[i].area_id]
  117.        
  118.         arrTemp.push(arrV);
  119.         }
  120.     }
  121.     var arrArea = arrTemp.filter(function (value, index, self) {
  122.         return self.indexOf(value) === index;
  123.       })
  124.        /*----- Add select text ------*/
  125.     arrV = ['<Select Area>','0']
  126.     arrArea.splice(0, 0, arrV);
  127.  
  128.     {dialog.Object}.populateDropdownBox('AREA_NAME',arrArea,false);
  129.     /*--- set to select text ----*/
  130.     setTimeout(function(){{dialog.Object}.setValue('AREA_NAME','0',false )} ,10);
  131.     } else {
  132.     {dialog.Object}.populateDropdownBox('AREA_NAME',arrTemp,true);
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement