Notifications
Clear all

[Closed] dropdownlist priority

I am getting a undefined error, which if I understand correctly is due to the ‘ddl_Lesson’ being called (in ddl_Project dropdownlist) before it is defined.

I dont want to swap them around in the code as then the order in which they are displayed inside the rollout is illogical.

I have tried to find a way to tell the script to read the ddl_Lesson dropdown list first…but I cannot find this information or even know what it is called. If there is another solution to the one I am thinking of please share.

Thanks in advance for any help, code is below:


global lessonArr = #(#("A_one","A_two","A_three") ,#("B_one","B_two","B_three"),#("C_one","C_two","C_three"),#("D_one","D_two","D_three") )    
global projectArr = #("A_Project","B_Project","C_Project","D_Project")  
global i = 1    

rollout mainRoll "mainRollOut" height:200  
(   	
dropdownlist ddl_Project "Project" items:projectArr  		
on ddl_Project selected i do  		
(  			
ddl_Lesson.items = lessonArr[i]  		
)	  	
dropdownlist ddl_Lesson "Lesson" items:lessonArr[i]  
)	
  
createDialog mainRoll    
3 Replies

Hi,
you could use this alternative

global lessonArr = #(#("A_one","A_two","A_three") ,#("B_one","B_two","B_three"),#("C_one","C_two","C_three"),#("D_one","D_two","D_three") )    
global projectArr = #("A_Project","B_Project","C_Project","D_Project")  
global i = 1    

rollout mainRoll "mainRollOut" height:200  
(   	
dropdownlist ddl_Project "Project" items:projectArr  		
on ddl_Project selected i do  		
(  			
mainRoll.controls[2].items = lessonArr[i]  		
)	  	
dropdownlist ddl_Lesson "Lesson" items:lessonArr[i]  
)	
  
createDialog mainRoll  

I would propbably just swap the contorls though. Keep in mind that the method above is error-prone as the index of the ddl_Lesson control is hardcoded.

you don’t need to swap the order of the controls but you do need to put ddl_Lesson before ddl_Project’s event handler as shown below:

global lessonArr = #(#("A_one","A_two","A_three") ,#("B_one","B_two","B_three"),#("C_one","C_two","C_three"),#("D_one","D_two","D_three") )	
 global projectArr = #("A_Project","B_Project","C_Project","D_Project")  
 global i = 1	
 
 rollout mainRoll "mainRollOut" height:200  
 (	   
 dropdownlist ddl_Project "Project" items:projectArr		  
 dropdownlist ddl_Lesson "Lesson" items:lessonArr[i]  
 on ddl_Project selected i do		  
 (			  
 ddl_Lesson.items = lessonArr[i]		  
 )		  
 )

IMO rollouts should generally be defined in the following order to avoid any scope issues:
locals
controls
functions
event handlers

Sorry for the delay in responding, thanks for the help!

Col