cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

Enable Modal Radio Box Items based on predefined list

I am trying to Enable/Disable certain radio box buttons in a single radio box based on a list I have entering the Modal dialog with.

 

For instance, say my list is {2, 5} and my radio box has 5 buttons in it. When the Modal window opens, I only want buttons 2 and 5 (from the list, which is based on previous user input) to be enabled and buttons 1, 3, and 4 to be disabled.

 

I've tried to add a For loop and an If loop with a Contains formula into the setting up of the radio box, but they seems to only get called when a different button is clicked in the radio box, not when it is originally set up.

 

Any help would be greatly appreciated. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Enable Modal Radio Box Items based on predefined list

Would example like this help?

Names Default To Here(1);

//radiobox variables
enableList = {2,5};
rbItems = {"one", "two", "three", "four", "five"};
rb = Radio Box(rbItems);

//start as all disabled
For(i = 1, i <= N Items(rb << get items), i++,
	rb << enable item(i,0);
);

//enable based on enableList
For(i = 1, i <= N Items(enableList), i++,
	rb << enable item(enableList[i],1);
);
//change first selection to first in enableList (otherwise will be first in rbItems)
rb << Set(enableList[1], 1);

//create modal
ok_pressed = 0;
ex = New Window("Dialog() example",
	<<Modal,
	V List Box(
		rb,
		H List Box(
			Button Box("OK", ok_pressed = 1; rbSelection = rb << get),
			Button Box("Cancel", ok_pressed = 0)
		)
	)
);

If(ok_pressed == 1,
	show(rbSelection);
	show(rbItems[rbSelection]);
);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Enable Modal Radio Box Items based on predefined list

Would example like this help?

Names Default To Here(1);

//radiobox variables
enableList = {2,5};
rbItems = {"one", "two", "three", "four", "five"};
rb = Radio Box(rbItems);

//start as all disabled
For(i = 1, i <= N Items(rb << get items), i++,
	rb << enable item(i,0);
);

//enable based on enableList
For(i = 1, i <= N Items(enableList), i++,
	rb << enable item(enableList[i],1);
);
//change first selection to first in enableList (otherwise will be first in rbItems)
rb << Set(enableList[1], 1);

//create modal
ok_pressed = 0;
ex = New Window("Dialog() example",
	<<Modal,
	V List Box(
		rb,
		H List Box(
			Button Box("OK", ok_pressed = 1; rbSelection = rb << get),
			Button Box("Cancel", ok_pressed = 0)
		)
	)
);

If(ok_pressed == 1,
	show(rbSelection);
	show(rbItems[rbSelection]);
);
-Jarmo
Martin
Level V

Re: Enable Modal Radio Box Items based on predefined list

Thanks Jarmo!

 

This works exactly like I had hoped. I was not thinking of "pre setting up" the radio box, before showing it.

 

Martin

Recommended Articles