cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
hahahaqing
Level II

Loop through the check boxes to get the values

Hi All,

I want to generate an overlay plot using my script. The plot is overlaid by the “Device_Type” column in my data table. However, I would like to let the user choose which device type they want to include in the overlay plot. Therefore, I want to create a list of checkboxes in the user interface. Here is my code:

 

Close All( Data Tables, NoSave );//close all previous windows
dt1 =	Open("data_device.jmp");
		
		
//extract a list of unique device types
Summarize( dt1, byDevice = by( :Device_Type ) );

//user interface
stop_flag = 0;
win = New Window("user interface",
	<<Modal,
	<<ReturnResult,
	V List Box(
	Text Box ("Create an overlay plot"),
	p3_box = H List Box(),
		db = {},
		For (i=1, i<= N items(byDevice),i++,
		db[i] = checkbox((byDevice[i]));
		p3_box << Append(db[i]);
		),
	H List Box(
		Button Box("OK",
			For (i=1, i<= N items(byDevice),i++,
			 db_gen [i] = db[i] << Get(i);
			),
		),
		Button Box("Cancel",
			stop_flag = 1;
		),
	),
	),
);

The checkboxes can be created successfully as below, but I was wondering how could I loop through the checkboxes to get the value for each checkbox?

 

box.PNG

 

Any help would be really appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Loop through the check boxes to get the values

If, for whatever reason, you still want to use the check boxes in your window, you do not need to iterate over each box if you use the default vertical orientation:

 

Names Default to Here( 1 );

items = { "One", "Two", "Three" };

New Window( "Check This", << Modal,
	Panel Box( "Items",
		cb = Check Box( items )
	),
	H List Box(
		Button Box( "OK",
			which = cb << Get Selected;
			where = cb << Get Selected Indices;
		)
	)
);

Show( which, where );

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Loop through the check boxes to get the values

Please paste a copy of the JSL into your response using the jsl.PNGso that the community can just copy and paste into JMP to work on your discussion item.  You can also attach the JSL as a separate file.  Otherwise, each Community member will have to manually retype in your JSL in order to work on it.

 

You may also want to rethink your approach.  I believe you can get what you want using a Local Data Filter, which would allow the user to Dynamically change the Overlay plot rather than just allowing one setting and then having to rerun the code to make a different selection of devices

.jsl2.PNG

Jim
hahahaqing
Level II

Re: Loop through the check boxes to get the values

I've fixed that! Thanks a lot!

Re: Loop through the check boxes to get the values

If, for whatever reason, you still want to use the check boxes in your window, you do not need to iterate over each box if you use the default vertical orientation:

 

Names Default to Here( 1 );

items = { "One", "Two", "Three" };

New Window( "Check This", << Modal,
	Panel Box( "Items",
		cb = Check Box( items )
	),
	H List Box(
		Button Box( "OK",
			which = cb << Get Selected;
			where = cb << Get Selected Indices;
		)
	)
);

Show( which, where );
hahahaqing
Level II

Re: Loop through the check boxes to get the values

It helps a lot! Thank you so much!