cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • See how to interactively organize and restructure data for analysis. Register for May 29 webinar, 2pm US ET.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
JMewborn
Level II

How to call a function or process when checkbox is checked

I have a Panel Box with multiple checkboxes in it. I want to be able to add additional checkboxes to the panel when one checkbox is selected.  For instance when I check CbBox2, I want the entire HLBox1 to be added to the window. Is this possible in JSL? See code below: 

HLBox1 = H List Box(
		spacer Box(Size(20,20)),
		CbBox3 = Check Box( "Additional Option Only to Appear if CbBox2 is selected." );
		CbBox3 << Set(0)
	);

GUIWindow1 = New Window("Preset Selections",
	PanelBox("Single option1, option 2, or Both",
	CbBox1 = Check Box( "Box 1 Option" ),
	CbBox2 = Check Box( "Box 2 Option" ),
	SpacerBox(Size(5,5)),
	
	CbBox1 << set( 1 ), 
	CbBox2 << set( 0 )
	),
	
);
Josh
2 REPLIES 2

Re: How to call a function or process when checkbox is checked

You can associate an anonymous function when you call Check Box() to create the display box.

 

GUIWindow1 = New Window("Preset Selections",
	PanelBox("Single option1, option 2, or Both",
	CbBox1 = Check Box( "Box 1 Option",
		<< Set Function(
			Function( { cb }, { temp },
				temp = cb << Get;
				// anything you need to do
			)
		)
	),
	CbBox2 = Check Box( "Box 2 Option" ),
	SpacerBox(Size(5,5)),
	
	CbBox1 << set( 1 ), 
	CbBox2 << set( 0 )
	)	
);
txnelson
Super User

Re: How to call a function or process when checkbox is checked

Use the message

     << set items

 

There is a good example of this in the Scripting Index, under the entry for

     CheckBoxBox

Names Default To Here( 1 );
New Window( "Example",
	cb = Check Box(
		{"One", "Two", "Three"},
		Print( "Selected: " || Concat Items( cb << Get Selected(), ", " ) )
	)
);
Wait( 2 );
cb << Set Items( {"a", "Four", "Five", "Six"} );
Jim

Recommended Articles