cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

In the following script, I would like to do the following:

Based on the selection of TestTech, I want the appropriate TestStage check box list to appear (appear is preferred, if not become active if all options need to be visible). So,

  • if Tech1 is selected, all TestSages with _Tech1 should be available to the user for selection
  • if Tech2 is selected, all TestSages with _Tech2 should be available to the user for selection. This list is commented below
  • if Tech3 is selected, all TestSages with _Tech3 should be available to the user for selection. This list is commented below, and so on.

I would also like "Select All" option to be available under each checkbox list.

How to do this?

 

Names Default To Here( 1 );
Clear Log ();

listInd = {};
returned2 = {};

win = New Window( "Select Tech & TestStage", << modal,
   	
   V List Box (
   
   tb1=Text Box("Select Tech", << set font style("bold")),
	
	cb1 = List Box(
		{"Tech1", "Tech2", "Tech3"}, 
		returned1 = (cb1 << Get Selected()); 
		listInd= cb1 << Get Selected Indices; 
	   ),
	
	tb1=Text Box("Select one or more TestStage", << set font style("bold")),
	
	cb2 = Check Box(
		{"Sage1_Tech1", "Sage2_Tech1", "Sage3_Tech1", "Sage4_Tech1", "Sage5_Tech1", "Sage6_Tech1"},
	    //{"Sage1_Tech2", "Sage2_Tech2", "Sage3_Tech2", "Sage4_Tech2", "Sage5_Tech2", "Sage6_Tech2"},
	    //{"Sage1_Tech3", "Sage2_Tech3", "Sage3_Tech3", "Sage4_Tech3", "Sage5_Tech3", "Sage6_Tech3"},
		returned2 = (cb2 << Get Selected());
		),
	
	tb3=Text Box("Query TestDate (last 6 months selected by default)", << set font style("bold")),
	
	end_date = Today();
	start_date = Date Increment(end_date, "month", -6, "actual");
	
	cb3 =	H List Box(
		Text Box("From:"),
		scal = Number Edit Box(
			start_date,
			<<Set Format(Format("yyyy-mm-dd")),
			<<SetFunction(Function({this}, start_date = scal << Get)),
			<<Set Show Spin Box(1)
		),
		Spacer Box(Size(20, 20)),
		Text Box("To:"),
		ecal = Number Edit Box(
			end_date,
			<<Set Format(Format("yyyy-mm-dd")),
			<<SetFunction(Function({this}, end_date = ecal << Get)),
			<<Set Show Spin Box(1)
		),

	);
	
),	
	
);

Technology = eval (returned1[1]); show (Technology);
TestStages  = eval (returned2); show (TestStages);
TestStageOne  = TestStages[1]; show (TestStageOne );

sdt = Munger( Format Date( start_date, "yyyy-mm-dd" ), 1, "T", " " );
edt = Munger( Format Date( end_date, "yyyy-mm-dd" ), 1, "T", " " ); 

Show( sdt, edt );

 

 

When it's too good to be true, it's neither
24 REPLIES 24
Neo
Neo
Level VI

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

@jthi Not sure why you repeat posted your original script, but this is where I have got to, still not working as needed, perhaps end looks near ?

Names Default To Here(1);
clear log ();

listInd = {}; p = N Items (listInd); 

lb_values = {"Tech1", "Tech2", "Tech3"};
cb_values = {"Sage1_Tech1", "Sage2_Tech1", "Sage3_Tech1", "Sage4_Tech1", "Sage5_Tech1", "Sage6_Tech1",
	         "Sage1_Tech2", "Sage2_Tech2", "Sage3_Tech2", "Sage4_Tech2", "Sage5_Tech2", "Sage6_Tech2",
	         "Sage1_Tech3", "Sage2_Tech3", "Sage3_Tech3", "Sage4_Tech3", "Sage5_Tech3", "Sage6_Tech3"
            };

expr_update_cb = Expr(
	
	cur_sel = lb << get selected;
	
	If(N Items(cur_sel),  cur_cb_values = Filter Each({val}, cb_values, cur_tech = Word(2, val, "_"); Contains(cur_sel, cur_tech))
	,
		cur_cb_values = cb_values;
	);
	
	p = N Items(cur_sel);
	cb2 << Set items(cur_cb_values); show (cur_cb_values);
);

win = New Window("Select Tech & TestStage", <<modal, 
	V List Box(
		tb1 = Text Box("Select Tech", <<set font style("bold")), 
		lb = List Box({"Tech1", "Tech2", "Tech3"}, 
		      listInd= lb << Get Selected Indices;  show (listInd );
		      expr_update_cb;
		      show (p);
		),
		show (p);
		tb2 = Text Box("Select one or more TestStage", <<set font style("bold")), 
		V List Box(	
		     if (p==0, cb2 ={}, p==1,
		     cb2 = Check Box(cb_values), 
		     ),
			H List Box(
				Button Box("Select All", cb2 << Set All(1)),
				Button Box("Clear All", cb2 << Set All(0))
			)
		),

		tb3 = Text Box(	"Query TestDate (last 6 months selected by default)", <<set font style("bold")), 
		end_date = Today();
		start_date = Date Increment(end_date, "month", -6, "actual");
		cb3 = H List Box(
			Text Box("From:"),
			scal = Number Edit Box(
				start_date,
				<<Set Format(Format("yyyy-mm-dd")),
				<<SetFunction(Function({this}, start_date = scal << Get)),
				<<Set Show Spin Box(1)
			),
			Spacer Box(Size(20, 20)),
			Text Box("To:"),
			ecal = Number Edit Box(
				end_date,
				<<Set Format(Format("yyyy-mm-dd")),
				<<SetFunction(Function({this}, end_date = ecal << Get)),
				<<Set Show Spin Box(1)
			)
		);
	)
);

 

When it's too good to be true, it's neither
jthi
Super User

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

Most likely my broken ctrl didn't let me copy correct script and I posted too quickly. It should be fixed now.

-Jarmo
Neo
Neo
Level VI

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

@jthi Thanks. Your updated script from today is working. I would be interested to know if the way I was doing it today (my script from today) is an incorrect approach.

Also, why does the date query not show if I put tb3 and cb3 sections at the top i.e. above tb1?

(idea is to get the user to choose the dates before anything else) 

When it's too good to be true, it's neither
jthi
Super User

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

My guess is that you are missing "," or you have ";" in wrong place

-Jarmo
Neo
Neo
Level VI

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

@jthi  my ","  placement seems correct but I still cannot get date query to work when placed at the top. 

Also, how to return the value selected by "select all"? My original placement for returned2 only seems to work for manual selection.

When it's too good to be true, it's neither
jthi
Super User

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

I would just get all values into variables when user presses OK not when user changes their selections.

-Jarmo
Neo
Neo
Level VI

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

@jthi Thanks, but I can only get manual selections retuned with my placement of returned2 inside the cb2=Check Box (.. .

Please could you point me to where to place cb2 << Get Selected();  to fire only when the user presses OK.

When it's too good to be true, it's neither
jthi
Super User

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

Scripting Guide > Display Trees > Modal Windows in JSL > Construct a Modal Window gives explanation of new windows using modal. And this should give an example where to place commands to get values into variables

Names Default To Here(1);
nw = New Window("Example", <<modal, <<return result,
	Panel Box("Options",
		cb = Check Box({"One", "Two", "Three"})
	),
	Panel Box("Actions",
		Lineup Box(N Col(2),
			Button Box("OK",
				cb_sel = cb << get selected;
			),
			Button Box("Cancel")
		)
	)
);

If(nw["Button"] != 1,
	stop();
);

show(cb);

You could also place that to << On Validate or << On Close (see Scripting Index for example and some explanation) but I usually place them inside the OK button.

-Jarmo
Neo
Neo
Level VI

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

@jthi, Thanks.

show(cb_sel);

works.

When it's too good to be true, it's neither
Neo
Neo
Level VI

Re: How to get check boxes to be change (or become visible or active) based on a previous selection in a modal window?

@jthi While I am on this topic (and not creating a new thread asking a new but related question), I am wondering if it is possible to show a text showing the user what each test stage did when the user selects it. Example pasted below.  Text only shows when selection is made and remains until unchecked. 

Neo_0-1702488383263.png

 

When it's too good to be true, it's neither